Skip to content

Commit 8993bb0

Browse files
committed
Remove usage of String.prototype.normalize
1 parent 2ae4d25 commit 8993bb0

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/index.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,9 +2827,9 @@ describe("path-to-regexp", function() {
28272827
const input = encodeURI("/cafe\u0301");
28282828

28292829
expect(exec(re, input)).toEqual(null);
2830-
expect(exec(re, pathToRegexp.normalizePathname(input))).toEqual([
2831-
"/caf\u00E9"
2832-
]);
2830+
expect(
2831+
exec(re, pathToRegexp.normalizePathname(input).normalize())
2832+
).toEqual(["/caf\u00E9"]);
28332833
});
28342834

28352835
it("should not normalize whitelisted characters", function() {

src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ export function normalizePathname(
2727
.replace(/\/+/g, "/")
2828
.replace(
2929
/(?:%[ef][0-9a-f](?:%[0-9a-f]{2}){2}|%[cd][0-9a-f]%[0-9a-f]{2}|%[0-9a-f]{2})/gi,
30-
function(m) {
30+
m => {
3131
const char = decodeURIComponent(m);
3232
if (whitelist.indexOf(char) > -1) return m;
3333
return char;
3434
}
35-
)
36-
.normalize();
35+
);
3736
}
3837

3938
/**
@@ -68,8 +67,7 @@ function balanced(open: string, close: string, str: string, index: number) {
6867
/**
6968
* Parse a string for the raw tokens.
7069
*/
71-
export function parse(input: string, options: ParseOptions = {}): Token[] {
72-
const str = input.normalize();
70+
export function parse(str: string, options: ParseOptions = {}): Token[] {
7371
const tokens = [];
7472
const defaultDelimiter = options.delimiter ?? DEFAULT_DELIMITER;
7573
const whitelist = options.whitelist ?? undefined;

0 commit comments

Comments
 (0)