chore: remove dead code in urlMatches (#33714)
This commit is contained in:
parent
d3ffdefd50
commit
77d82b8b07
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue