Skip to content

Commit 63cb664

Browse files
fix(base-driver): update dependency path-to-regexp to v8 (#20520)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Mykola Mokhnach <mokhnach@gmail.com>
1 parent 51c3063 commit 63cb664

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

package-lock.json

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

packages/base-driver/lib/express/middleware.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import _ from 'lodash';
22
import log from './logger';
33
import {errors} from '../protocol';
44
export {handleIdempotency} from './idempotency';
5-
import {pathToRegexp} from 'path-to-regexp';
5+
import {match} from 'path-to-regexp';
66
import {util} from '@appium/support';
77
import {calcSignature} from '../helpers/session';
88

@@ -119,7 +119,7 @@ export function handleUpgrade(webSocketsMapping) {
119119
currentPathname = req.url ?? '';
120120
}
121121
for (const [pathname, wsServer] of _.toPairs(webSocketsMapping)) {
122-
if (pathToRegexp(pathname).test(currentPathname)) {
122+
if (match(pathname)(currentPathname)) {
123123
return wsServer.handleUpgrade(req, req.socket, Buffer.from(''), (ws) => {
124124
wsServer.emit('connection', ws, req);
125125
});

packages/base-driver/lib/protocol/routes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import _ from 'lodash';
44
import {util} from '@appium/support';
55
import {PROTOCOLS, DEFAULT_BASE_PATH} from '../constants';
6-
import {pathToRegexp} from 'path-to-regexp';
6+
import {match} from 'path-to-regexp';
77

88
const SET_ALERT_TEXT_PAYLOAD_PARAMS = {
99
validate: (jsonObj) =>
@@ -952,8 +952,8 @@ export function routeToCommandName(endpoint, method, basePath = DEFAULT_BASE_PAT
952952
possiblePathnames.push(normalizedPathname);
953953
const normalizedMethod = _.toUpper(method);
954954
for (const [routePath, routeSpec] of _.toPairs(METHOD_MAP)) {
955-
const routeRegexp = pathToRegexp(routePath);
956-
if (possiblePathnames.some((pp) => routeRegexp.test(pp))) {
955+
const routeMatcher = match(routePath);
956+
if (possiblePathnames.some((pp) => routeMatcher(pp))) {
957957
const commandName = routeSpec?.[normalizedMethod]?.command;
958958
if (commandName) {
959959
return commandName;

packages/base-driver/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"lru-cache": "10.4.3",
6565
"method-override": "3.0.0",
6666
"morgan": "1.10.0",
67-
"path-to-regexp": "7.1.0",
67+
"path-to-regexp": "8.0.0",
6868
"serve-favicon": "2.5.0",
6969
"source-map-support": "0.5.21",
7070
"type-fest": "4.26.0",
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import {pathToRegexp} from 'path-to-regexp';
1+
import {match} from 'path-to-regexp';
22

33
describe('middleware', function () {
44
before(async function () {
55
const chai = await import('chai');
66
chai.should();
77
});
88

9-
describe('pathToRegexp', function () {
9+
describe('match', function () {
1010
it('should match static path pattern', function () {
1111
const pathname = '/ws/session/1234/appium/device/syslog';
1212
const url = 'ws://127.0.0.1:8000/ws/session/1234/appium/device/syslog';
1313
const currentPathname = new URL(url).pathname;
14-
pathToRegexp(pathname).test(currentPathname).should.be.true;
14+
match(pathname)(currentPathname).should.not.be.false;
1515
});
1616

1717
it('should match dynamic path pattern', function () {
1818
const pathname = '/ws/session/:sessionId/appium/device/syslog';
1919
const url = 'ws://127.0.0.1:8000/ws/session/1234/appium/device/syslog';
2020
const currentPathname = new URL(url).pathname;
21-
pathToRegexp(pathname).test(currentPathname).should.be.true;
21+
match(pathname)(currentPathname).should.not.be.false;
2222
});
2323
});
2424
});

0 commit comments

Comments
 (0)