mirror of
https://github.com/appium/appium.git
synced 2026-02-23 03:40:15 -06:00
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>
This commit is contained in:
16
package-lock.json
generated
16
package-lock.json
generated
@@ -19403,7 +19403,7 @@
|
||||
"lru-cache": "10.4.3",
|
||||
"method-override": "3.0.0",
|
||||
"morgan": "1.10.0",
|
||||
"path-to-regexp": "7.1.0",
|
||||
"path-to-regexp": "8.0.0",
|
||||
"serve-favicon": "2.5.0",
|
||||
"source-map-support": "0.5.21",
|
||||
"type-fest": "4.26.0",
|
||||
@@ -19433,9 +19433,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"packages/base-driver/node_modules/path-to-regexp": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-7.1.0.tgz",
|
||||
"integrity": "sha512-ZToe+MbUF4lBqk6dV8GKot4DKfzrxXsplOddH8zN3YK+qw9/McvP7+4ICjZvOne0jQhN4eJwHsX6tT0Ns19fvw==",
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.0.0.tgz",
|
||||
"integrity": "sha512-GAWaqWlTjYK/7SVpIUA6CTxmcg65SP30sbjdCvyYReosRkk7Z/LyHWwkK3Vu0FcIi0FNTADUs4eh1AsU5s10cg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
@@ -20639,7 +20639,7 @@
|
||||
"lru-cache": "10.4.3",
|
||||
"method-override": "3.0.0",
|
||||
"morgan": "1.10.0",
|
||||
"path-to-regexp": "7.1.0",
|
||||
"path-to-regexp": "8.0.0",
|
||||
"serve-favicon": "2.5.0",
|
||||
"source-map-support": "0.5.21",
|
||||
"spdy": "4.0.2",
|
||||
@@ -20661,9 +20661,9 @@
|
||||
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="
|
||||
},
|
||||
"path-to-regexp": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-7.1.0.tgz",
|
||||
"integrity": "sha512-ZToe+MbUF4lBqk6dV8GKot4DKfzrxXsplOddH8zN3YK+qw9/McvP7+4ICjZvOne0jQhN4eJwHsX6tT0Ns19fvw=="
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.0.0.tgz",
|
||||
"integrity": "sha512-GAWaqWlTjYK/7SVpIUA6CTxmcg65SP30sbjdCvyYReosRkk7Z/LyHWwkK3Vu0FcIi0FNTADUs4eh1AsU5s10cg=="
|
||||
},
|
||||
"type-fest": {
|
||||
"version": "4.26.0",
|
||||
|
||||
@@ -2,7 +2,7 @@ import _ from 'lodash';
|
||||
import log from './logger';
|
||||
import {errors} from '../protocol';
|
||||
export {handleIdempotency} from './idempotency';
|
||||
import {pathToRegexp} from 'path-to-regexp';
|
||||
import {match} from 'path-to-regexp';
|
||||
import {util} from '@appium/support';
|
||||
import {calcSignature} from '../helpers/session';
|
||||
|
||||
@@ -119,7 +119,7 @@ export function handleUpgrade(webSocketsMapping) {
|
||||
currentPathname = req.url ?? '';
|
||||
}
|
||||
for (const [pathname, wsServer] of _.toPairs(webSocketsMapping)) {
|
||||
if (pathToRegexp(pathname).test(currentPathname)) {
|
||||
if (match(pathname)(currentPathname)) {
|
||||
return wsServer.handleUpgrade(req, req.socket, Buffer.from(''), (ws) => {
|
||||
wsServer.emit('connection', ws, req);
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import _ from 'lodash';
|
||||
import {util} from '@appium/support';
|
||||
import {PROTOCOLS, DEFAULT_BASE_PATH} from '../constants';
|
||||
import {pathToRegexp} from 'path-to-regexp';
|
||||
import {match} from 'path-to-regexp';
|
||||
|
||||
const SET_ALERT_TEXT_PAYLOAD_PARAMS = {
|
||||
validate: (jsonObj) =>
|
||||
@@ -952,8 +952,8 @@ export function routeToCommandName(endpoint, method, basePath = DEFAULT_BASE_PAT
|
||||
possiblePathnames.push(normalizedPathname);
|
||||
const normalizedMethod = _.toUpper(method);
|
||||
for (const [routePath, routeSpec] of _.toPairs(METHOD_MAP)) {
|
||||
const routeRegexp = pathToRegexp(routePath);
|
||||
if (possiblePathnames.some((pp) => routeRegexp.test(pp))) {
|
||||
const routeMatcher = match(routePath);
|
||||
if (possiblePathnames.some((pp) => routeMatcher(pp))) {
|
||||
const commandName = routeSpec?.[normalizedMethod]?.command;
|
||||
if (commandName) {
|
||||
return commandName;
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
"lru-cache": "10.4.3",
|
||||
"method-override": "3.0.0",
|
||||
"morgan": "1.10.0",
|
||||
"path-to-regexp": "7.1.0",
|
||||
"path-to-regexp": "8.0.0",
|
||||
"serve-favicon": "2.5.0",
|
||||
"source-map-support": "0.5.21",
|
||||
"type-fest": "4.26.0",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {pathToRegexp} from 'path-to-regexp';
|
||||
import {match} from 'path-to-regexp';
|
||||
|
||||
describe('middleware', function () {
|
||||
before(async function () {
|
||||
@@ -6,19 +6,19 @@ describe('middleware', function () {
|
||||
chai.should();
|
||||
});
|
||||
|
||||
describe('pathToRegexp', function () {
|
||||
describe('match', function () {
|
||||
it('should match static path pattern', function () {
|
||||
const pathname = '/ws/session/1234/appium/device/syslog';
|
||||
const url = 'ws://127.0.0.1:8000/ws/session/1234/appium/device/syslog';
|
||||
const currentPathname = new URL(url).pathname;
|
||||
pathToRegexp(pathname).test(currentPathname).should.be.true;
|
||||
match(pathname)(currentPathname).should.not.be.false;
|
||||
});
|
||||
|
||||
it('should match dynamic path pattern', function () {
|
||||
const pathname = '/ws/session/:sessionId/appium/device/syslog';
|
||||
const url = 'ws://127.0.0.1:8000/ws/session/1234/appium/device/syslog';
|
||||
const currentPathname = new URL(url).pathname;
|
||||
pathToRegexp(pathname).test(currentPathname).should.be.true;
|
||||
match(pathname)(currentPathname).should.not.be.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user