You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `normalizePathname` function will return a normalized string for matching with `pathToRegexp`.
167
+
The `normalizePathname` function will return a normalized string for matching with `pathToRegexp`:
175
168
176
169
```js
177
170
constre=pathToRegexp("/caf\u00E9");
178
-
constinput=encodeURI("/cafe\u0301");
171
+
constinput=encodeURI("/caf\u00E9");
179
172
180
173
re.test(input); //=> false
181
174
re.test(normalizePathname(input)); //=> true
182
175
```
183
176
177
+
**Note:** It may be preferable to implement something in your own library that normalizes the pathname for matching. E.g. [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) automatically URI encodes paths for you, which would result in a consistent match.
178
+
179
+
**Tip:** Consider using [`String.prototype.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) to resolve unicode variants of the same string.
180
+
184
181
### Parse
185
182
186
183
The `parse` function will return a list of strings and keys from a path string:
0 commit comments