Skip to content

Commit

Permalink
chore: remove dead code in urlMatches (#33714)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Nov 21, 2024
1 parent d3ffdef commit 77d82b8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/src/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Browser builds for Firefox and WebKit are built for the [glibc](https://en.wikip
You can use the [.NET install script](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script) in order to install different SDK versions:

```bash
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --install-dir /usr/share/dotnet --channel 6.0
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --install-dir /usr/share/dotnet --channel 9.0
```

## Build your own image
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/frames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ export class Frame extends SdkObject {
origin(): string | undefined {
if (!this._url.startsWith('http'))
return;
return network.parsedURL(this._url)?.origin;
return network.parseURL(this._url)?.origin;
}

parentFrame(): Frame | null {
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/har/harTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class HarTracer {
const page = request.frame()?._page;
if (this._page && page !== this._page)
return;
const url = network.parsedURL(request.url());
const url = network.parseURL(request.url());
if (!url)
return;

Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function rewriteCookies(cookies: channels.SetNetworkCookie[]): channels.S
});
}

export function parsedURL(url: string): URL | null {
export function parseURL(url: string): URL | null {
try {
return new URL(url);
} catch (e) {
Expand Down
8 changes: 2 additions & 6 deletions packages/playwright-core/src/utils/isomorphic/urlMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,15 @@ export function urlMatches(baseURL: string | undefined, urlString: string, match
match = globToRegex(match);
if (isRegExp(match))
return match.test(urlString);
if (typeof match === 'string' && match === urlString)
return true;
const url = parsedURL(urlString);
const url = parseURL(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 {
function parseURL(url: string): URL | null {
try {
return new URL(url);
} catch (e) {
Expand Down

0 comments on commit 77d82b8

Please sign in to comment.