Skip to content

Commit aed49b1

Browse files
authored
fix: unicode chars were extracting with double slashes (#1035)
1 parent d2bb0b6 commit aed49b1

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

packages/macro/src/macroJs.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe("js macro", () => {
8787
expect(tokens).toEqual([
8888
{
8989
type: "text",
90-
value: 'Message \\u0020',
90+
value: 'Message \/u0020',
9191
},
9292
])
9393
})

packages/macro/src/macroJs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ export default class MacroJs {
361361
*/
362362
clearBackslashes(value: string) {
363363
// it's an unicode char so we should keep them
364-
if (value.includes('\\u')) return value
364+
if (value.includes('\\u')) return value.replace(removeExtraScapedLiterals, "\/u")
365365
// if not we replace the extra scaped literals
366366
return value.replace(removeExtraScapedLiterals, "`")
367367
}

packages/macro/src/macroJsx.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { zip, makeCounter } from "./utils"
77
import { ID, COMMENT, MESSAGE } from "./constants"
88

99
const pluralRuleRe = /(_[\d\w]+|zero|one|two|few|many|other)/
10-
const removeExtraScapedLiterals = /(?:\\(.))/
10+
const removeExtraScapedLiterals = /(?:\\(.))/g
1111
const jsx2icuExactChoice = (value) =>
1212
value.replace(/_(\d+)/, "=$1").replace(/_(\w+)/, "$1")
1313

@@ -365,7 +365,7 @@ export default class MacroJSX {
365365
* */
366366
clearBackslashes(value: string) {
367367
// it's an unicode char so we should keep them
368-
if (value.includes('\\u')) return value
368+
if (value.includes('\\u')) return value.replace(removeExtraScapedLiterals, "\/u")
369369
// if not we replace the extra scaped literals
370370
return value.replace(removeExtraScapedLiterals, "`")
371371
}

0 commit comments

Comments
 (0)