-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Not sure if this makes sense when having the escape spec in mind (you know that way better!), but what if a character is already escaped within the string to escape? The current code will double escape escaped stuff, I'm using a custom version that doesn't do that, e.g. changed to this:
// If the character is not handled by one of the above rules and is
// greater than or equal to U+0080, is `-` (U+002D) or `\` (U+005C) or
// `_` (U+005F), or is preceded by a `\` (escape) already,
// or is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
// U+005A), or [a-z] (U+0061 to U+007A), […]
if (
codeUnit >= 0x0080 ||
codeUnit == 0x002D ||
codeUnit == 0x005C || // custom: no double escapes!
codeUnit == 0x005F ||
string.charCodeAt(index-1) == 0x005C || // custom: no double escapes!
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
codeUnit >= 0x0061 && codeUnit <= 0x007A
) {
// the character itself
result += string.charAt(index);
continue;
}if this makes any sense for this project I'm glad to open a PR with the change, but I can imagine it is either against the spec, the purpose of this module or will break backward compatibility and can therefore not be done...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels