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
* New option! Ability to set `endsWith` to match paths like `/test?query=string` up to the query string * New option! Set `delimiters` for specific characters to be treated as parameter prefixes (e.g. `/:test`) * Remove `isarray` dependency * Explicitly handle trailing delimiters instead of trimming them (e.g. `/test/` is now treated as `/test/` instead of `/test` when matching) * Remove overloaded `keys` argument that accepted `options` * Remove `keys` list attached to the `RegExp` output * Remove asterisk functionality (it's a real pain to properly encode) * Change `tokensToFunction` (e.g. `compile`) to accept an `encode` function for pretty encoding (e.g. pass your own implementation)
**Please note:** The `RegExp` returned by `path-to-regexp` is intended for use with pathnames or hostnames. It can not handle the query strings or fragments of a URL.
46
+
**Please note:** The `RegExp` returned by `path-to-regexp` is intended for ordered data (e.g. pathnames, hostnames). It does not handle arbitrary data (e.g. query strings, URL fragments, JSON, etc).
44
47
45
48
### Parameters
46
49
47
-
The path string can be used to define parameters and populate the keys.
50
+
The path argument is used to define parameters and populate the list of keys.
48
51
49
52
#### Named Parameters
50
53
51
54
Named parameters are defined by prefixing a colon to the parameter name (`:foo`). By default, the parameter will match until the following path segment.
All parameters can be provided a custom regexp, which overrides the default (`[^\/]+`).
121
126
122
127
```js
123
-
var re =pathToRegexp('/:foo(\\d+)', keys)
128
+
var re =pathToRegexp('/:foo(\\d+)')
124
129
// keys = [{ name: 'foo', ... }]
125
130
126
131
re.exec('/123')
@@ -137,25 +142,13 @@ re.exec('/abc')
137
142
It is possible to write an unnamed parameter that only consists of a matching group. It works the same as a named parameter, except it will be numerically indexed.
0 commit comments