Skip to content

Commit

Permalink
Merge pull request #353 from AppQuality/develop
Browse files Browse the repository at this point in the history
feat: Allow parentheses in escape char
  • Loading branch information
d-beezee authored Oct 2, 2024
2 parents 28a43a9 + 99a8f16 commit f3a910f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/features/escapeCharacters/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import escapeCharacters from ".";

describe("escapeCharacters", () => {
it("should escape characters", () => {
const result = escapeCharacters(
"string with 'special' (characters)<script>call()</script>"
);
expect(result).toBe("string with 'special' (characters)scriptcall()script");
});
});
2 changes: 1 addition & 1 deletion src/features/escapeCharacters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default (value: string) => {
/[^\x00-\x7F]/g,
(a) => "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4)
)
.replace(/(([A-Za-zÀ-ÿ' 0-9,-]|\\u[0-9a-z]*))/gmu, (a) => (ret += a));
.replace(/(([A-Za-zÀ-ÿ' 0-9,-]|\(|\)|\\u[0-9a-z]*))/gmu, (a) => (ret += a));
return ret.replace(/\\u[0-9a-z]{4}/gmu, function (a) {
return String.fromCharCode(parseInt(a.slice(2), 16));
});
Expand Down

0 comments on commit f3a910f

Please sign in to comment.