Skip to content

Commit 764ae1a

Browse files
alexpech12fatso83
andauthored
Update path-to-regexp to 8.1.0 (fix CVE-2024-45296) (#226)
* Update path-to-regexp package to 8.1.0 * Use updated API of pathToRegexp * Fix prettier * Use new path-to-regexp wildcard syntax when parsing url * Add a small comment that hints the reader at what the strange syntax is about --------- Co-authored-by: Carl-Erik Kopseng <[email protected]>
1 parent da6f09c commit 764ae1a

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

lib/fake-server/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,10 @@ var fakeServer = {
250250
url = url.replace("://", "\\://");
251251
}
252252
if (/\*/.test(url)) {
253+
// Uses the new syntax for repeating parameters in path-to-regexp,
254+
// see https://github.com/pillarjs/path-to-regexp#unexpected--or-
253255
// eslint-disable-next-line no-param-reassign
254-
url = url.replace(/\/\*/g, "/(.*)");
256+
url = url.replace(/\/\*/g, "/*path");
255257
}
256258

257259
if (this.legacyRoutes) {
@@ -261,11 +263,12 @@ var fakeServer = {
261263
}
262264
}
263265
}
264-
265266
push.call(this.responses, {
266267
method: method,
267268
url:
268-
typeof url === "string" && url !== "" ? pathToRegexp(url) : url,
269+
typeof url === "string" && url !== ""
270+
? pathToRegexp(url).regexp
271+
: url,
269272
response: typeof body === "function" ? body : responseArray(body),
270273
});
271274
},

package-lock.json

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"@sinonjs/fake-timers": "^11.2.2",
6868
"@sinonjs/text-encoding": "^0.7.2",
6969
"just-extend": "^6.2.0",
70-
"path-to-regexp": "^6.2.1"
70+
"path-to-regexp": "^8.1.0"
7171
},
7272
"lint-staged": {
7373
"*.{js,css,md}": "prettier --check",

0 commit comments

Comments
 (0)