chore: remove dead code in urlMatches (#33714)

This commit is contained in:
Max Schmitt 2024-11-21 15:53:28 +01:00 committed by GitHub
parent d3ffdefd50
commit 77d82b8b07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 6 additions and 10 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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;

View File

@ -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) {

View File

@ -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) {