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
fix: allow matching against `about:blank` and other custom URLs (#36180)
Adam Gastineau4b40a743d1b4
diff --git a/packages/playwright-core/src/utils/isomorphic/urlMatch.ts b/packages/playwright-core/src/utils/isomorphic/urlMatch.tsindex 35965191c9..0ba1715e7f 100644--- a/packages/playwright-core/src/utils/isomorphic/urlMatch.ts+++ b/packages/playwright-core/src/utils/isomorphic/urlMatch.ts@@ -127,6 +127,9 @@ function resolveGlobBase(baseURL: string | undefined, match: string): string {}// Escaped `\\?` behaves the same as `?` in our glob patterns.match = match.replaceAll(/\\\\\?/g, '?');+ // Special case about: URLs as they are not relative to baseURL+ if (match.startsWith('about:'))+ return match;// Glob symbols may be escaped in the URL and some of them such as ? affect resolution,// so we replace them with safe components first.const relativePath = match.split('/').map((token, index) => {diff --git a/tests/page/interception.spec.ts b/tests/page/interception.spec.tsindex 80c94d0854..6812c16400 100644--- a/tests/page/interception.spec.ts+++ b/tests/page/interception.spec.ts@@ -128,6 +128,12 @@ it('should work with glob', async () => {expect(urlMatches('http://playwright.dev/foo', 'http://playwright.dev/foo?bar', '\\\\?bar')).toBeTruthy();expect(urlMatches('http://first.host/', 'http://second.host/foo', '**/foo')).toBeTruthy();expect(urlMatches('http://playwright.dev/', 'http://localhost/', '*//localhost/')).toBeTruthy();++ expect(urlMatches('http://playwright.dev/', 'about:blank', 'about:blank')).toBeTruthy();+ expect(urlMatches('http://playwright.dev/', 'about:blank', 'http://playwright.dev/')).toBeFalsy();+ expect(urlMatches(undefined, 'about:blank', 'about:blank')).toBeTruthy();+ expect(urlMatches(undefined, 'about:blank', 'about:*')).toBeTruthy();+ expect(urlMatches(undefined, 'notabout:blank', 'about:*')).toBeFalsy();});it('should intercept by glob', async function({ page, server, isAndroid }) {