mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
clean test cases
This commit is contained in:
1 parent
d2ab0bd05a
commit
1bcd8da415
5 files changed
+5
-37
No files matched your search
@@ -175,27 +175,20 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
|
||||
return createTemplateExpression(head, templateSpans);
|
||||
}
|
||||
|
||||
const hexToUnicode = (_match: string, grp: string) => String.fromCharCode(parseInt(grp, 16));
|
||||
const octalToUnicode = (_match: string, grp: string) => String.fromCharCode(parseInt(grp, 8));
|
||||
|
||||
function decodeRawString(content: string) {
|
||||
const outerQuotes = /["']((.|\s)*)["']/;
|
||||
const unicodeEscape = /\\u(\w+)/gi;
|
||||
const unicodeEscapeWithBraces = /\\u\{(\w+)\}/gi;
|
||||
const hexEscape = /\\x(\w+)/gi;
|
||||
const octalEscape = /\\([0-7]+)/g;
|
||||
const octalEscape = /\\((?:[1-7][0-7]{0,2}|[0-7]{2,3}))/g;
|
||||
|
||||
return content.replace(outerQuotes, (_match, grp) => grp)
|
||||
.replace(unicodeEscape, hexToUnicode)
|
||||
.replace(unicodeEscapeWithBraces, hexToUnicode)
|
||||
.replace(hexEscape, hexToUnicode)
|
||||
.replace(octalEscape, octalToUnicode);
|
||||
|
||||
}
|
||||
|
||||
function escapeText(content: string) {
|
||||
return content.replace("`", "\`") // back-tick
|
||||
.replace("\${", `$\\{`); // placeholder alike beginning
|
||||
.replace("${", "$\\{"); // placeholder alike beginning
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user