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
**Note:**[`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) automatically encodes pathnames for you.
195
+
196
+
##### Alternative Using Normalize
197
+
198
+
Sometimes you won't have an already normalized pathname. You can normalize it yourself before processing:
187
199
188
200
```js
189
201
/**
@@ -202,15 +214,14 @@ function normalizePathname(pathname: string) {
202
214
);
203
215
}
204
216
217
+
// Two possible ways of writing `/café`:
205
218
constre=pathToRegexp("/caf\u00E9");
206
219
constinput=encodeURI("/cafe\u0301");
207
220
208
221
re.test(input); //=> false
209
222
re.test(normalizePathname(input)); //=> true
210
223
```
211
224
212
-
**Note:**[`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) automatically encodes pathnames for you, which would result in a consistent match if you use `encodeURI` in `pathToRegexp` options.
213
-
214
225
### Parse
215
226
216
227
The `parse` function will return a list of strings and keys from a path string:
0 commit comments