Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: move urlMatch to isomorphic (#32142)
Dmitry Gozmanf8eef3897c0f
diff --git a/packages/playwright-core/src/client/browserContext.ts b/packages/playwright-core/src/client/browserContext.tsindex 3eb8214ca5..5991fcafd9 100644--- a/packages/playwright-core/src/client/browserContext.ts+++ b/packages/playwright-core/src/client/browserContext.ts@@ -28,9 +28,8 @@ import { Worker } from './worker';import { Events } from './events';import { TimeoutSettings } from '../common/timeoutSettings';import { Waiter } from './waiter';-import type { URLMatch, Headers, WaitForEventOptions, BrowserContextOptions, StorageState, LaunchOptions } from './types';-import { headersObjectToArray, isRegExp, isString, urlMatchesEqual } from '../utils';-import { mkdirIfNeeded } from '../utils/fileUtils';+import type { Headers, WaitForEventOptions, BrowserContextOptions, StorageState, LaunchOptions } from './types';+import { type URLMatch, headersObjectToArray, isRegExp, isString, urlMatchesEqual, mkdirIfNeeded } from '../utils';import type * as api from '../../types/types';import type * as structs from '../../types/structs';import { CDPSession } from './cdpSession';diff --git a/packages/playwright-core/src/client/frame.ts b/packages/playwright-core/src/client/frame.tsindex a7ceeb9456..c337077630 100644--- a/packages/playwright-core/src/client/frame.ts+++ b/packages/playwright-core/src/client/frame.ts@@ -30,9 +30,9 @@ import type { Page } from './page';import { EventEmitter } from 'events';import { Waiter } from './waiter';import { Events } from './events';-import type { LifecycleEvent, URLMatch, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions, StrictOptions } from './types';+import type { LifecycleEvent, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions, StrictOptions } from './types';import { kLifecycleEvents } from './types';-import { urlMatches } from '../utils/network';+import { type URLMatch, urlMatches } from '../utils';import type * as api from '../../types/types';import type * as structs from '../../types/structs';import { addSourceUrlToScript } from './clientHelper';diff --git a/packages/playwright-core/src/client/harRouter.ts b/packages/playwright-core/src/client/harRouter.tsindex 5fe32a39be..5e617d7ce9 100644--- a/packages/playwright-core/src/client/harRouter.ts+++ b/packages/playwright-core/src/client/harRouter.ts@@ -18,7 +18,7 @@ import { debugLogger } from '../utils/debugLogger';import type { BrowserContext } from './browserContext';import type { LocalUtils } from './localUtils';import type { Route } from './network';-import type { URLMatch } from './types';+import type { URLMatch } from '../utils';import type { Page } from './page';type HarNotFoundAction = 'abort' | 'fallback';diff --git a/packages/playwright-core/src/client/network.ts b/packages/playwright-core/src/client/network.tsindex 2e28b6cd1b..164af0f7e2 100644--- a/packages/playwright-core/src/client/network.ts+++ b/packages/playwright-core/src/client/network.ts@@ -28,9 +28,8 @@ import { Events } from './events';import type { Page } from './page';import { Waiter } from './waiter';import type * as api from '../../types/types';-import type { HeadersArray, URLMatch } from '../common/types';-import { urlMatches } from '../utils/network';-import { MultiMap } from '../utils/multimap';+import type { HeadersArray } from '../common/types';+import { MultiMap, urlMatches, type URLMatch } from '../utils';import { APIResponse } from './fetch';import type { Serializable } from '../../types/structs';import type { BrowserContext } from './browserContext';diff --git a/packages/playwright-core/src/client/page.ts b/packages/playwright-core/src/client/page.tsindex 84848e433d..a10286fa9a 100644--- a/packages/playwright-core/src/client/page.ts+++ b/packages/playwright-core/src/client/page.ts@@ -20,11 +20,9 @@ import path from 'path';import type * as structs from '../../types/structs';import type * as api from '../../types/types';import { serializeError, isTargetClosedError, TargetClosedError } from './errors';-import { urlMatches } from '../utils/network';import { TimeoutSettings } from '../common/timeoutSettings';import type * as channels from '@protocol/channels';-import { assert, headersObjectToArray, isObject, isRegExp, isString, LongStandingScope, urlMatchesEqual } from '../utils';-import { mkdirIfNeeded } from '../utils/fileUtils';+import { assert, headersObjectToArray, isObject, isRegExp, isString, LongStandingScope, urlMatches, urlMatchesEqual, mkdirIfNeeded, trimStringWithEllipsis, type URLMatch } from '../utils';import { Accessibility } from './accessibility';import { Artifact } from './artifact';import type { BrowserContext } from './browserContext';@@ -42,9 +40,8 @@ import { Keyboard, Mouse, Touchscreen } from './input';import { assertMaxArguments, JSHandle, parseResult, serializeArgument } from './jsHandle';import type { FrameLocator, Locator, LocatorOptions } from './locator';import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils';-import { trimStringWithEllipsis } from '../utils/isomorphic/stringUtils';import { type RouteHandlerCallback, type Request, Response, Route, RouteHandler, validateHeaders, WebSocket } from './network';-import type { FilePayload, Headers, LifecycleEvent, SelectOption, SelectOptionOptions, Size, URLMatch, WaitForEventOptions, WaitForFunctionOptions } from './types';+import type { FilePayload, Headers, LifecycleEvent, SelectOption, SelectOptionOptions, Size, WaitForEventOptions, WaitForFunctionOptions } from './types';import { Video } from './video';import { Waiter } from './waiter';import { Worker } from './worker';diff --git a/packages/playwright-core/src/client/types.ts b/packages/playwright-core/src/client/types.tsindex 1eb28f38c9..8101257280 100644--- a/packages/playwright-core/src/client/types.ts+++ b/packages/playwright-core/src/client/types.ts@@ -17,7 +17,7 @@import type * as channels from '@protocol/channels';import type { Size } from '../common/types';-export type { Size, Point, Rect, Quad, URLMatch, TimeoutOptions, HeadersArray } from '../common/types';+export type { Size, Point, Rect, Quad, TimeoutOptions, HeadersArray } from '../common/types';type LoggerSeverity = 'verbose' | 'info' | 'warning' | 'error';export interface Logger {diff --git a/packages/playwright-core/src/common/types.ts b/packages/playwright-core/src/common/types.tsindex e179b8c4a1..55145b5565 100644--- a/packages/playwright-core/src/common/types.ts+++ b/packages/playwright-core/src/common/types.ts@@ -18,7 +18,6 @@ export type Size = { width: number, height: number };export type Point = { x: number, y: number };export type Rect = Size & Point;export type Quad = [ Point, Point, Point, Point ];-export type URLMatch = string | RegExp | ((url: URL) => boolean);export type TimeoutOptions = { timeout?: number };export type NameValue = { name: string, value: string };export type HeadersArray = NameValue[];\ No newline at end of filediff --git a/packages/playwright-core/src/inProcessFactory.ts b/packages/playwright-core/src/inProcessFactory.tsindex f38589f0b2..1397c81958 100644--- a/packages/playwright-core/src/inProcessFactory.ts+++ b/packages/playwright-core/src/inProcessFactory.ts@@ -19,7 +19,7 @@ import { createPlaywright, DispatcherConnection, RootDispatcher, PlaywrightDispaimport { Connection } from './client/connection';import { BrowserServerLauncherImpl } from './browserServerImpl';import { AndroidServerLauncherImpl } from './androidServerImpl';-import type { Language } from './utils/isomorphic/locatorGenerators';+import type { Language } from './utils';export function createInProcessPlaywright(): PlaywrightAPI {const playwright = createPlaywright({ sdkLanguage: (process.env.PW_LANG_NAME as Language | undefined) || 'javascript' });diff --git a/packages/playwright-core/src/server/debugController.ts b/packages/playwright-core/src/server/debugController.tsindex ea2dc9a805..1d87485571 100644--- a/packages/playwright-core/src/server/debugController.ts+++ b/packages/playwright-core/src/server/debugController.ts@@ -23,8 +23,7 @@ import type { InstrumentationListener } from './instrumentation';import type { Playwright } from './playwright';import { Recorder } from './recorder';import { EmptyRecorderApp } from './recorder/recorderApp';-import { asLocator } from '../utils/isomorphic/locatorGenerators';-import type { Language } from '../utils/isomorphic/locatorGenerators';+import { asLocator, type Language } from '../utils';const internalMetadata = serverSideCallMetadata();diff --git a/packages/playwright-core/src/server/frameSelectors.ts b/packages/playwright-core/src/server/frameSelectors.tsindex 951f9a8945..66f2e2e514 100644--- a/packages/playwright-core/src/server/frameSelectors.ts+++ b/packages/playwright-core/src/server/frameSelectors.ts@@ -20,7 +20,7 @@ import { stringifySelector, type ParsedSelector, splitSelectorByFrame, InvalidSeimport type { FrameExecutionContext, ElementHandle } from './dom';import type { JSHandle } from './javascript';import type { InjectedScript } from './injected/injectedScript';-import { asLocator } from '../utils/isomorphic/locatorGenerators';+import { asLocator } from '../utils';export type SelectorInfo = {parsed: ParsedSelector,diff --git a/packages/playwright-core/src/server/frames.ts b/packages/playwright-core/src/server/frames.tsindex 3ca952774f..87569f00d6 100644--- a/packages/playwright-core/src/server/frames.ts+++ b/packages/playwright-core/src/server/frames.ts@@ -29,7 +29,7 @@ import * as types from './types';import { BrowserContext } from './browserContext';import type { Progress } from './progress';import { ProgressController } from './progress';-import { LongStandingScope, assert, constructURLBasedOnBaseURL, makeWaitForNextTask, monotonicTime } from '../utils';+import { LongStandingScope, assert, constructURLBasedOnBaseURL, makeWaitForNextTask, monotonicTime, asLocator } from '../utils';import { ManualPromise } from '../utils/manualPromise';import { debugLogger } from '../utils/debugLogger';import type { CallMetadata } from './instrumentation';@@ -38,7 +38,6 @@ import type { InjectedScript, ElementStateWithoutStable, FrameExpectParams } froimport { isSessionClosedError } from './protocolError';import { type ParsedSelector, isInvalidSelectorError } from '../utils/isomorphic/selectorParser';import type { ScreenshotOptions } from './screenshotter';-import { asLocator } from '../utils/isomorphic/locatorGenerators';import { FrameSelectors } from './frameSelectors';import { TimeoutError } from './errors';import { prepareFilesForUpload } from './fileUploadUtils';diff --git a/packages/playwright-core/src/server/har/harTracer.ts b/packages/playwright-core/src/server/har/harTracer.tsindex cb423a144d..e6330f3889 100644--- a/packages/playwright-core/src/server/har/harTracer.ts+++ b/packages/playwright-core/src/server/har/harTracer.ts@@ -27,11 +27,9 @@ import type { RegisteredListener } from '../../utils/eventsHelper';import { eventsHelper } from '../../utils/eventsHelper';import { mime } from '../../utilsBundle';import { ManualPromise } from '../../utils/manualPromise';-import { getPlaywrightVersion } from '../../utils/userAgent';-import { urlMatches } from '../../utils/network';+import { getPlaywrightVersion, isTextualMimeType, urlMatches } from '../../utils';import { Frame } from '../frames';import type { HeadersArray, LifecycleEvent } from '../types';-import { isTextualMimeType } from '../../utils/isomorphic/mimeType';const FALLBACK_HTTP_VERSION = 'HTTP/1.1';diff --git a/packages/playwright-core/src/server/page.ts b/packages/playwright-core/src/server/page.tsindex fe37e16269..e0436968ec 100644--- a/packages/playwright-core/src/server/page.ts+++ b/packages/playwright-core/src/server/page.ts@@ -44,7 +44,7 @@ import { isInvalidSelectorError } from '../utils/isomorphic/selectorParser';import { parseEvaluationResultValue, source } from './isomorphic/utilityScriptSerializers';import type { SerializedValue } from './isomorphic/utilityScriptSerializers';import { TargetClosedError } from './errors';-import { asLocator } from '../utils/isomorphic/locatorGenerators';+import { asLocator } from '../utils';export interface PageDelegate {readonly rawMouse: input.RawMouse;diff --git a/packages/playwright-core/src/server/playwright.ts b/packages/playwright-core/src/server/playwright.tsindex 3d524ad959..f33c2b3699 100644--- a/packages/playwright-core/src/server/playwright.ts+++ b/packages/playwright-core/src/server/playwright.ts@@ -24,10 +24,9 @@ import { Selectors } from './selectors';import { WebKit } from './webkit/webkit';import type { CallMetadata } from './instrumentation';import { createInstrumentation, SdkObject } from './instrumentation';-import { debugLogger } from '../utils/debugLogger';+import { debugLogger, type Language } from '../utils';import type { Page } from './page';import { DebugController } from './debugController';-import type { Language } from '../utils/isomorphic/locatorGenerators';import type { BrowserType } from './browserType';type PlaywrightOptions = {diff --git a/packages/playwright-core/src/server/recorder.ts b/packages/playwright-core/src/server/recorder.tsindex 3a770741ae..93f706581f 100644--- a/packages/playwright-core/src/server/recorder.ts+++ b/packages/playwright-core/src/server/recorder.ts@@ -43,8 +43,7 @@ import { EventEmitter } from 'events';import { raceAgainstDeadline } from '../utils/timeoutRunner';import type { Language, LanguageGenerator } from './recorder/language';import { locatorOrSelectorAsSelector } from '../utils/isomorphic/locatorParser';-import { quoteCSSAttributeValue } from '../utils/isomorphic/stringUtils';-import { eventsHelper, type RegisteredListener } from './../utils/eventsHelper';+import { quoteCSSAttributeValue, eventsHelper, type RegisteredListener } from '../utils';import type { Dialog } from './dialog';type BindingSource = { frame: Frame, page: Page };diff --git a/packages/playwright-core/src/server/recorder/csharp.ts b/packages/playwright-core/src/server/recorder/csharp.tsindex 461b33e944..52460f8121 100644--- a/packages/playwright-core/src/server/recorder/csharp.ts+++ b/packages/playwright-core/src/server/recorder/csharp.ts@@ -21,9 +21,8 @@ import type { ActionInContext } from './codeGenerator';import type { Action } from './recorderActions';import type { MouseClickOptions } from './utils';import { toModifiers } from './utils';-import { escapeWithQuotes } from '../../utils/isomorphic/stringUtils';+import { escapeWithQuotes, asLocator } from '../../utils';import { deviceDescriptors } from '../deviceDescriptors';-import { asLocator } from '../../utils/isomorphic/locatorGenerators';type CSharpLanguageMode = 'library' | 'mstest' | 'nunit';diff --git a/packages/playwright-core/src/server/recorder/java.ts b/packages/playwright-core/src/server/recorder/java.tsindex f38b026a37..72d5d9a995 100644--- a/packages/playwright-core/src/server/recorder/java.ts+++ b/packages/playwright-core/src/server/recorder/java.ts@@ -23,8 +23,7 @@ import type { MouseClickOptions } from './utils';import { toModifiers } from './utils';import { deviceDescriptors } from '../deviceDescriptors';import { JavaScriptFormatter } from './javascript';-import { escapeWithQuotes } from '../../utils/isomorphic/stringUtils';-import { asLocator } from '../../utils/isomorphic/locatorGenerators';+import { escapeWithQuotes, asLocator } from '../../utils';type JavaLanguageMode = 'library' | 'junit';diff --git a/packages/playwright-core/src/server/recorder/javascript.ts b/packages/playwright-core/src/server/recorder/javascript.tsindex 9bafcd6574..104b3bcd53 100644--- a/packages/playwright-core/src/server/recorder/javascript.ts+++ b/packages/playwright-core/src/server/recorder/javascript.ts@@ -22,8 +22,7 @@ import type { Action } from './recorderActions';import type { MouseClickOptions } from './utils';import { toModifiers } from './utils';import { deviceDescriptors } from '../deviceDescriptors';-import { escapeWithQuotes } from '../../utils/isomorphic/stringUtils';-import { asLocator } from '../../utils/isomorphic/locatorGenerators';+import { escapeWithQuotes, asLocator } from '../../utils';export class JavaScriptLanguageGenerator implements LanguageGenerator {id: string;diff --git a/packages/playwright-core/src/server/recorder/jsonl.ts b/packages/playwright-core/src/server/recorder/jsonl.tsindex 636aaae70f..108d5eadc6 100644--- a/packages/playwright-core/src/server/recorder/jsonl.ts+++ b/packages/playwright-core/src/server/recorder/jsonl.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { asLocator } from '../../utils/isomorphic/locatorGenerators';+import { asLocator } from '../../utils';import type { ActionInContext } from './codeGenerator';import type { Language, LanguageGenerator, LanguageGeneratorOptions } from './language';diff --git a/packages/playwright-core/src/server/recorder/language.ts b/packages/playwright-core/src/server/recorder/language.tsindex 87b1a8fac4..cee2b22163 100644--- a/packages/playwright-core/src/server/recorder/language.ts+++ b/packages/playwright-core/src/server/recorder/language.ts@@ -15,10 +15,10 @@*/import type { BrowserContextOptions, LaunchOptions } from '../../..';-import type { Language } from '../../utils/isomorphic/locatorGenerators';+import type { Language } from '../../utils';import type { ActionInContext } from './codeGenerator';import type { Action, DialogSignal, DownloadSignal, PopupSignal } from './recorderActions';-export type { Language } from '../../utils/isomorphic/locatorGenerators';+export type { Language } from '../../utils';export type LanguageGeneratorOptions = {browserName: string;diff --git a/packages/playwright-core/src/server/recorder/python.ts b/packages/playwright-core/src/server/recorder/python.tsindex ec592840ab..d393fb38e4 100644--- a/packages/playwright-core/src/server/recorder/python.ts+++ b/packages/playwright-core/src/server/recorder/python.ts@@ -21,9 +21,8 @@ import type { ActionInContext } from './codeGenerator';import type { Action } from './recorderActions';import type { MouseClickOptions } from './utils';import { toModifiers } from './utils';-import { escapeWithQuotes, toSnakeCase } from '../../utils/isomorphic/stringUtils';+import { escapeWithQuotes, toSnakeCase, asLocator } from '../../utils';import { deviceDescriptors } from '../deviceDescriptors';-import { asLocator } from '../../utils/isomorphic/locatorGenerators';export class PythonLanguageGenerator implements LanguageGenerator {id: string;diff --git a/packages/playwright-core/src/server/types.ts b/packages/playwright-core/src/server/types.tsindex 66ebf2014c..226216c397 100644--- a/packages/playwright-core/src/server/types.ts+++ b/packages/playwright-core/src/server/types.ts@@ -16,7 +16,7 @@*/import type { Size, Point, TimeoutOptions, HeadersArray } from '../common/types';-export type { Size, Point, Rect, Quad, URLMatch, TimeoutOptions, HeadersArray } from '../common/types';+export type { Size, Point, Rect, Quad, TimeoutOptions, HeadersArray } from '../common/types';import type * as channels from '@protocol/channels';export type StrictOptions = {diff --git a/packages/playwright-core/src/utils/index.ts b/packages/playwright-core/src/utils/index.tsindex 67ec09d91d..372922ec59 100644--- a/packages/playwright-core/src/utils/index.ts+++ b/packages/playwright-core/src/utils/index.ts@@ -18,15 +18,18 @@ export * from './ascii';export * from './comparators';export * from './crypto';export * from './debug';+export * from './debugLogger';export * from './env';export * from './eventsHelper';export * from './fileUtils';-export * from './glob';export * from './headers';export * from './hostPlatform';export * from './httpServer';export * from './manualPromise';+export * from './isomorphic/locatorGenerators';export * from './isomorphic/mimeType';+export * from './isomorphic/stringUtils';+export * from './isomorphic/urlMatch';export * from './multimap';export * from './network';export * from './processLauncher';@@ -43,5 +46,3 @@ export * from './userAgent';export * from './wsServer';export * from './zipFile';export * from './zones';-export * from './isomorphic/locatorGenerators';-export * from './isomorphic/stringUtils';diff --git a/packages/playwright-core/src/utils/isomorphic/locatorParser.ts b/packages/playwright-core/src/utils/isomorphic/locatorParser.tsindex d9bbca2f7e..2ad5fd29c6 100644--- a/packages/playwright-core/src/utils/isomorphic/locatorParser.ts+++ b/packages/playwright-core/src/utils/isomorphic/locatorParser.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { escapeForAttributeSelector, escapeForTextSelector } from '../../utils/isomorphic/stringUtils';+import { escapeForAttributeSelector, escapeForTextSelector } from './stringUtils';import { asLocators } from './locatorGenerators';import type { Language, Quote } from './locatorGenerators';import { parseSelector } from './selectorParser';diff --git a/packages/playwright-core/src/utils/glob.ts b/packages/playwright-core/src/utils/isomorphic/urlMatch.tssimilarity index 59%rename from packages/playwright-core/src/utils/glob.tsrename to packages/playwright-core/src/utils/isomorphic/urlMatch.tsindex b464fc9a24..b20d47d220 100644--- a/packages/playwright-core/src/utils/glob.ts+++ b/packages/playwright-core/src/utils/isomorphic/urlMatch.ts@@ -14,6 +14,8 @@* limitations under the License.*/+import { isString } from './stringUtils';+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escapingconst escapedChars = new Set(['$', '^', '+', '.', '*', '(', ')', '|', '\\', '?', '{', '}', '[', ']']);@@ -79,3 +81,52 @@ export function globToRegex(glob: string): RegExp {tokens.push('$');return new RegExp(tokens.join(''));}++function isRegExp(obj: any): obj is RegExp {+ return obj instanceof RegExp || Object.prototype.toString.call(obj) === '[object RegExp]';+}++export type URLMatch = string | RegExp | ((url: URL) => boolean);++export function urlMatchesEqual(match1: URLMatch, match2: URLMatch) {+ if (isRegExp(match1) && isRegExp(match2))+ return match1.source === match2.source && match1.flags === match2.flags;+ return match1 === match2;+}++export function urlMatches(baseURL: string | undefined, urlString: string, match: URLMatch | undefined): boolean {+ if (match === undefined || match === '')+ return true;+ if (isString(match) && !match.startsWith('*'))+ match = constructURLBasedOnBaseURL(baseURL, match);+ if (isString(match))+ match = globToRegex(match);+ if (isRegExp(match))+ return match.test(urlString);+ if (typeof match === 'string' && match === urlString)+ return true;+ const url = parsedURL(urlString);+ if (!url)+ return false;+ if (typeof match === 'string')+ return url.pathname === match;+ if (typeof match !== 'function')+ throw new Error('url parameter should be string, RegExp or function');+ return match(url);+}++function parsedURL(url: string): URL | null {+ try {+ return new URL(url);+ } catch (e) {+ return null;+ }+}++export function constructURLBasedOnBaseURL(baseURL: string | undefined, givenURL: string): string {+ try {+ return (new URL(givenURL, baseURL)).toString();+ } catch (e) {+ return givenURL;+ }+}diff --git a/packages/playwright-core/src/utils/network.ts b/packages/playwright-core/src/utils/network.tsindex b9bc2c0f06..f04b828d67 100644--- a/packages/playwright-core/src/utils/network.ts+++ b/packages/playwright-core/src/utils/network.ts@@ -22,9 +22,6 @@ import type net from 'net';import { getProxyForUrl } from '../utilsBundle';import { HttpsProxyAgent } from '../utilsBundle';import url from 'url';-import type { URLMatch } from '../common/types';-import { isString, isRegExp } from './rtti';-import { globToRegex } from './glob';import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent } from './happy-eyeballs';export type HTTPRequestParams = {@@ -111,49 +108,6 @@ export function fetchData(params: HTTPRequestParams, onError?: (params: HTTPRequ});}-export function urlMatchesEqual(match1: URLMatch, match2: URLMatch) {- if (isRegExp(match1) && isRegExp(match2))- return match1.source === match2.source && match1.flags === match2.flags;- return match1 === match2;-}--export function urlMatches(baseURL: string | undefined, urlString: string, match: URLMatch | undefined): boolean {- if (match === undefined || match === '')- return true;- if (isString(match) && !match.startsWith('*'))- match = constructURLBasedOnBaseURL(baseURL, match);- if (isString(match))- match = globToRegex(match);- if (isRegExp(match))- return match.test(urlString);- if (typeof match === 'string' && match === urlString)- return true;- const url = parsedURL(urlString);- if (!url)- return false;- if (typeof match === 'string')- return url.pathname === match;- if (typeof match !== 'function')- throw new Error('url parameter should be string, RegExp or function');- return match(url);-}--function parsedURL(url: string): URL | null {- try {- return new URL(url);- } catch (e) {- return null;- }-}--export function constructURLBasedOnBaseURL(baseURL: string | undefined, givenURL: string): string {- try {- return (new URL(givenURL, baseURL)).toString();- } catch (e) {- return givenURL;- }-}-export function createHttpServer(requestListener?: (req: http.IncomingMessage, res: http.ServerResponse) => void): http.Server;export function createHttpServer(options: http.ServerOptions, requestListener?: (req: http.IncomingMessage, res: http.ServerResponse) => void): http.Server;export function createHttpServer(...args: any[]): http.Server {diff --git a/tests/page/interception.spec.ts b/tests/page/interception.spec.tsindex d71675cc39..fd798cb715 100644--- a/tests/page/interception.spec.ts+++ b/tests/page/interception.spec.ts@@ -16,7 +16,7 @@*/import { test as it, expect } from './pageTest';-import { globToRegex } from '../../packages/playwright-core/lib/utils/glob';+import { globToRegex } from '../../packages/playwright-core/lib/utils/isomorphic/urlMatch';import vm from 'vm';it('should work with navigation @smoke', async ({ page, server }) => {