Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ exports[`generateMessageFunction > development 1`] = `

exports[`generateMessageFunction > escapeHtml > default: should not be escaped 1`] = `"(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["<p>hello</p>"])};fn.source="<p>hello</p>";return fn;})()"`;

exports[`generateMessageFunction > escapeHtml > true: should be escaped 1`] = `"(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;p&gt;hello&lt;/p&gt;"])};fn.source="<p>hello</p>";return fn;})()"`;
exports[`generateMessageFunction > escapeHtml > true: should be escaped 1`] = `"(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;p&gt;hello&lt;&#x2F;p&gt;"])};fn.source="<p>hello</p>";return fn;})()"`;

exports[`generateMessageFunction > production 1`] = `
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ const resource = {
"unicode": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["A"])};fn.source="A";return fn;})(),
"unicode-escape": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\u0041"])};fn.source="\\\\u0041";return fn;})(),
"backslash-single-quote": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\'"])};fn.source="\\\\'";return fn;})(),
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\\\\\"])};fn.source="\\\\\\\\";return fn;})(),
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\"])};fn.source="\\\\\\\\";return fn;})(),
"errors": [
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1001"])};fn.source="ERROR1001";return fn;})(),
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1002"])};fn.source="ERROR1002";return fn;})()
Expand Down Expand Up @@ -372,8 +372,8 @@ exports[`force stringify > map 1`] = `

exports[`html tag in message > code 1`] = `
"{
"hi": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;p&gt;hi there!&lt;/p&gt;"])};fn.source="<p>hi there!</p>";return fn;})(),
"alert": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;script&gt;window.alert(&apos;hi there!&apos;)&lt;/script&gt;"])};fn.source="<script>window.alert('hi there!')</script>";return fn;})()
"hi": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;p&gt;hi there!&lt;&#x2F;p&gt;"])};fn.source="<p>hi there!</p>";return fn;})(),
"alert": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;script&gt;window.alert(&apos;hi there!&apos;)&lt;&#x2F;script&gt;"])};fn.source="<script>window.alert('hi there!')</script>";return fn;})()
}"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ exports[`AST code generation > complex > code 1`] = `
"unicode": {"type":0,"start":0,"end":1,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":2,"offset":1},"source":"A"},"body":{"type":2,"start":0,"end":1,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":2,"offset":1}},"items":[{"type":3,"start":0,"end":1,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":2,"offset":1}}}],"static":"A"}},
"unicode-escape": {"type":0,"start":0,"end":6,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":7,"offset":6},"source":"\\\\u0041"},"body":{"type":2,"start":0,"end":6,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":7,"offset":6}},"items":[{"type":3,"start":0,"end":6,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":7,"offset":6}}}],"static":"\\\\u0041"}},
"backslash-single-quote": {"type":0,"start":0,"end":2,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":3,"offset":2},"source":"\\\\\\u0027"},"body":{"type":2,"start":0,"end":2,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":3,"offset":2}},"items":[{"type":3,"start":0,"end":2,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":3,"offset":2}}}],"static":"\\\\\\u0027"}},
"backslash-backslash": {"type":0,"start":0,"end":2,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":3,"offset":2},"source":"\\\\\\\\"},"body":{"type":2,"start":0,"end":2,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":3,"offset":2}},"items":[{"type":3,"start":0,"end":2,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":3,"offset":2}}}],"static":"\\\\\\\\"}},
"backslash-backslash": {"type":0,"start":0,"end":2,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":3,"offset":2},"source":"\\\\\\\\"},"body":{"type":2,"start":0,"end":2,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":3,"offset":2}},"items":[{"type":3,"start":0,"end":2,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":3,"offset":2}}}],"static":"\\\\"}},
"errors": [
{"type":0,"start":0,"end":9,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":10,"offset":9},"source":"ERROR1001"},"body":{"type":2,"start":0,"end":9,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":10,"offset":9}},"items":[{"type":3,"start":0,"end":9,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":10,"offset":9}}}],"static":"ERROR1001"}},
{"type":0,"start":0,"end":9,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":10,"offset":9},"source":"ERROR1002"},"body":{"type":2,"start":0,"end":9,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":10,"offset":9}},"items":[{"type":3,"start":0,"end":9,"loc":{"start":{"line":1,"column":1,"offset":0},"end":{"line":1,"column":10,"offset":9}}}],"static":"ERROR1002"}}
Expand Down Expand Up @@ -404,7 +404,7 @@ exports[`code generation > complex > code 1`] = `
"unicode": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["A"])};fn.source="A";return fn;})(),
"unicode-escape": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\u0041"])};fn.source="\\\\u0041";return fn;})(),
"backslash-single-quote": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\'"])};fn.source="\\\\'";return fn;})(),
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\\\\\"])};fn.source="\\\\\\\\";return fn;})(),
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\"])};fn.source="\\\\\\\\";return fn;})(),
"errors": [
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1001"])};fn.source="ERROR1001";return fn;})(),
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1002"])};fn.source="ERROR1002";return fn;})()
Expand Down Expand Up @@ -441,7 +441,7 @@ exports[`code generation > complex > map 1`] = `
"A",
"\\u0041",
"\\'",
"\\\\",
"\\",
"ERROR1001",
"ERROR1002",
"NOTE: This is warning",
Expand Down Expand Up @@ -522,8 +522,8 @@ exports[`code generation > force stringify > map 1`] = `

exports[`code generation > html tag in message > code 1`] = `
"{
"hi": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;p&gt;hi there!&lt;/p&gt;"])};fn.source="<p>hi there!</p>";return fn;})(),
"alert": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;script&gt;window.alert(&apos;hi there!&apos;)&lt;/script&gt;"])};fn.source="<script>window.alert('hi there!')</script>";return fn;})()
"hi": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;p&gt;hi there!&lt;&#x2F;p&gt;"])};fn.source="<p>hi there!</p>";return fn;})(),
"alert": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;script&gt;window.alert(&apos;hi there!&apos;)&lt;&#x2F;script&gt;"])};fn.source="<script>window.alert('hi there!')</script>";return fn;})()
}"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports[`AST code generation > code 1`] = `
"unicode": {"type":0,"body":{"type":2,"items":[{"type":3}],"static":"A"}},
"unicode-escape": {"type":0,"body":{"type":2,"items":[{"type":3}],"static":"\\\\u0041"}},
"backslash-single-quote": {"type":0,"body":{"type":2,"items":[{"type":3}],"static":"\\\\\\u0027"}},
"backslash-backslash": {"type":0,"body":{"type":2,"items":[{"type":3}],"static":"\\\\\\\\"}},
"backslash-backslash": {"type":0,"body":{"type":2,"items":[{"type":3}],"static":"\\\\"}},
"errors": [
{"type":0,"body":{"type":2,"items":[{"type":3}],"static":"ERROR1001"}},
{"type":0,"body":{"type":2,"items":[{"type":3}],"static":"ERROR1002"}}
Expand Down Expand Up @@ -49,7 +49,7 @@ exports[`json5 > code 1`] = `
"unicode": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["A"])};fn.source="A";return fn;})(),
"unicode-escape": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\u0041"])};fn.source="\\\\u0041";return fn;})(),
"backslash-single-quote": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\'"])};fn.source="\\\\'";return fn;})(),
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\\\\\"])};fn.source="\\\\\\\\";return fn;})(),
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\"])};fn.source="\\\\\\\\";return fn;})(),
"errors": [
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1001"])};fn.source="ERROR1001";return fn;})(),
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1002"])};fn.source="ERROR1002";return fn;})()
Expand Down Expand Up @@ -86,7 +86,7 @@ exports[`json5 > map 1`] = `
"A",
"\\u0041",
"\\'",
"\\\\",
"\\",
"ERROR1001",
"ERROR1002",
"NOTE: This is warning",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports[`AST code generation > code 1`] = `
"unicode": {"type":0,"body":{"type":2,"items":[{"type":3}],"static":"A"}},
"unicode-escape": {"type":0,"body":{"type":2,"items":[{"type":3}],"static":"\\\\u0041"}},
"backslash-single-quote": {"type":0,"body":{"type":2,"items":[{"type":3}],"static":"\\\\\\u0027"}},
"backslash-backslash": {"type":0,"body":{"type":2,"items":[{"type":3}],"static":"\\\\\\\\"}},
"backslash-backslash": {"type":0,"body":{"type":2,"items":[{"type":3}],"static":"\\\\"}},
"errors": [
{"type":0,"body":{"type":2,"items":[{"type":3}],"static":"ERROR1001"}},
{"type":0,"body":{"type":2,"items":[{"type":3}],"static":"ERROR1002"}},
Expand Down Expand Up @@ -160,8 +160,8 @@ exports[`bare > map 1`] = `

exports[`html tag in message > code 1`] = `
"{
"hi": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;p&gt;hi there!&lt;/p&gt;"])};fn.source="<p>hi there!</p>";return fn;})(),
"alert": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;script&gt;window.alert(&apos;hi there!&apos;)&lt;/script&gt;"])};fn.source="<script>window.alert('hi there!')</script>";return fn;})()
"hi": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;p&gt;hi there!&lt;&#x2F;p&gt;"])};fn.source="<p>hi there!</p>";return fn;})(),
"alert": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["&lt;script&gt;window.alert(&apos;hi there!&apos;)&lt;&#x2F;script&gt;"])};fn.source="<script>window.alert('hi there!')</script>";return fn;})()
}"
`;

Expand Down Expand Up @@ -313,7 +313,7 @@ exports[`yaml > code 1`] = `
"unicode": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["A"])};fn.source="A";return fn;})(),
"unicode-escape": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\u0041"])};fn.source="\\\\u0041";return fn;})(),
"backslash-single-quote": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\'"])};fn.source="\\\\'";return fn;})(),
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\\\\\"])};fn.source="\\\\\\\\";return fn;})(),
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\"])};fn.source="\\\\\\\\";return fn;})(),
"errors": [
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1001"])};fn.source="ERROR1001";return fn;})(),
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1002"])};fn.source="ERROR1002";return fn;})(),
Expand Down Expand Up @@ -351,7 +351,7 @@ exports[`yaml > map 1`] = `
"A",
"\\u0041",
"\\'",
"\\\\",
"\\",
"ERROR1001",
"ERROR1002",
"NOTE: This is warning",
Expand Down Expand Up @@ -405,7 +405,7 @@ exports[`yml > code 1`] = `
"unicode": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["A"])};fn.source="A";return fn;})(),
"unicode-escape": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\u0041"])};fn.source="\\\\u0041";return fn;})(),
"backslash-single-quote": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\'"])};fn.source="\\\\'";return fn;})(),
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\\\\\"])};fn.source="\\\\\\\\";return fn;})(),
"backslash-backslash": (()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["\\\\"])};fn.source="\\\\\\\\";return fn;})(),
"errors": [
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1001"])};fn.source="ERROR1001";return fn;})(),
(()=>{const fn=(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["ERROR1002"])};fn.source="ERROR1002";return fn;})(),
Expand Down Expand Up @@ -443,7 +443,7 @@ exports[`yml > map 1`] = `
"A",
"\\u0041",
"\\'",
"\\\\",
"\\",
"ERROR1001",
"ERROR1002",
"NOTE: This is warning",
Expand Down
4 changes: 2 additions & 2 deletions packages/unplugin-vue-i18n/test/resource-compilation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ test('escape message', async () => {
})
)
expect(compile(module.hi, {} as MessageCompilerContext)(createMessageContext())).toBe(
`&lt;p&gt;hi there!&lt;/p&gt;`
`&lt;p&gt;hi there!&lt;&#x2F;p&gt;`
)
expect(compile(module.alert, {} as MessageCompilerContext)(createMessageContext())).toBe(
`&lt;script&gt;window.alert(&apos;hi there!&apos;)&lt;/script&gt;`
`&lt;script&gt;window.alert(&apos;hi there!&apos;)&lt;&#x2F;script&gt;`
)
})
Loading
Loading