Skip to content

Commit 8e730f9

Browse files
authored
Revert globToRegex removal (#37089)
1 parent 2fb2784 commit 8e730f9

File tree

6 files changed

+37
-1
lines changed

6 files changed

+37
-1
lines changed

packages/playwright-core/src/protocol/validator.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,14 @@ scheme.LocalUtilsTraceDiscardedParams = tObject({
358358
stacksId: tString,
359359
});
360360
scheme.LocalUtilsTraceDiscardedResult = tOptional(tObject({}));
361+
scheme.LocalUtilsGlobToRegexParams = tObject({
362+
glob: tString,
363+
baseURL: tOptional(tString),
364+
webSocketUrl: tOptional(tBoolean),
365+
});
366+
scheme.LocalUtilsGlobToRegexResult = tObject({
367+
regex: tString,
368+
});
361369
scheme.RootInitializer = tOptional(tObject({}));
362370
scheme.RootInitializeParams = tObject({
363371
sdkLanguage: tType('SDKLanguage'),

packages/playwright-core/src/server/dispatchers/localUtilsDispatcher.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Progress } from '../progress';
2424
import { SocksInterceptor } from '../socksInterceptor';
2525
import { WebSocketTransport } from '../transport';
2626
import { fetchData } from '../utils/network';
27+
import { resolveGlobToRegexPattern } from '../../utils/isomorphic/urlMatch';
2728

2829
import type { HarBackend } from '../harBackend';
2930
import type { Playwright } from '../playwright';
@@ -116,6 +117,11 @@ export class LocalUtilsDispatcher extends Dispatcher<SdkObject, channels.LocalUt
116117
pipe.on('close', () => transport.close());
117118
return { pipe, headers: transport.headers };
118119
}
120+
121+
async globToRegex(params: channels.LocalUtilsGlobToRegexParams, progress: Progress): Promise<channels.LocalUtilsGlobToRegexResult> {
122+
const regex = resolveGlobToRegexPattern(params.baseURL, params.glob, params.webSocketUrl);
123+
return { regex };
124+
}
119125
}
120126

121127
async function urlToWSEndpoint(progress: Progress, endpointURL: string): Promise<string> {

packages/playwright-core/src/utils/isomorphic/protocolMetainfo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const methodMetainfo = new Map<string, { internal?: boolean, title?: stri
3232
['LocalUtils.tracingStarted', { internal: true, }],
3333
['LocalUtils.addStackToTracingNoReply', { internal: true, }],
3434
['LocalUtils.traceDiscarded', { internal: true, }],
35+
['LocalUtils.globToRegex', { internal: true, }],
3536
['Root.initialize', { internal: true, }],
3637
['Playwright.newRequest', { title: 'Create request context', }],
3738
['DebugController.initialize', { internal: true, }],

packages/playwright-core/src/utils/isomorphic/urlMatch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function urlMatches(baseURL: string | undefined, urlString: string, match
102102
return match(url);
103103
}
104104

105-
function resolveGlobToRegexPattern(baseURL: string | undefined, glob: string, webSocketUrl?: boolean): string {
105+
export function resolveGlobToRegexPattern(baseURL: string | undefined, glob: string, webSocketUrl?: boolean): string {
106106
if (webSocketUrl)
107107
baseURL = toWebSocketBaseUrl(baseURL);
108108
glob = resolveGlobBase(baseURL, glob);

packages/protocol/src/channels.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ export interface LocalUtilsChannel extends LocalUtilsEventTarget, Channel {
485485
tracingStarted(params: LocalUtilsTracingStartedParams, progress?: Progress): Promise<LocalUtilsTracingStartedResult>;
486486
addStackToTracingNoReply(params: LocalUtilsAddStackToTracingNoReplyParams, progress?: Progress): Promise<LocalUtilsAddStackToTracingNoReplyResult>;
487487
traceDiscarded(params: LocalUtilsTraceDiscardedParams, progress?: Progress): Promise<LocalUtilsTraceDiscardedResult>;
488+
globToRegex(params: LocalUtilsGlobToRegexParams, progress?: Progress): Promise<LocalUtilsGlobToRegexResult>;
488489
}
489490
export type LocalUtilsZipParams = {
490491
zipFile: string,
@@ -583,6 +584,18 @@ export type LocalUtilsTraceDiscardedOptions = {
583584

584585
};
585586
export type LocalUtilsTraceDiscardedResult = void;
587+
export type LocalUtilsGlobToRegexParams = {
588+
glob: string,
589+
baseURL?: string,
590+
webSocketUrl?: boolean,
591+
};
592+
export type LocalUtilsGlobToRegexOptions = {
593+
baseURL?: string,
594+
webSocketUrl?: boolean,
595+
};
596+
export type LocalUtilsGlobToRegexResult = {
597+
regex: string,
598+
};
586599

587600
export interface LocalUtilsEvents {
588601
}

packages/protocol/src/protocol.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,14 @@ LocalUtils:
766766
parameters:
767767
stacksId: string
768768

769+
globToRegex:
770+
internal: true
771+
parameters:
772+
glob: string
773+
baseURL: string?
774+
webSocketUrl: boolean?
775+
returns:
776+
regex: string
769777

770778
Root:
771779
type: interface

0 commit comments

Comments
 (0)