mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
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:
|
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
|
```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
|
## Build your own image
|
||||||
|
|||||||
@ -942,7 +942,7 @@ export class Frame extends SdkObject {
|
|||||||
origin(): string | undefined {
|
origin(): string | undefined {
|
||||||
if (!this._url.startsWith('http'))
|
if (!this._url.startsWith('http'))
|
||||||
return;
|
return;
|
||||||
return network.parsedURL(this._url)?.origin;
|
return network.parseURL(this._url)?.origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
parentFrame(): Frame | null {
|
parentFrame(): Frame | null {
|
||||||
|
|||||||
@ -257,7 +257,7 @@ export class HarTracer {
|
|||||||
const page = request.frame()?._page;
|
const page = request.frame()?._page;
|
||||||
if (this._page && page !== this._page)
|
if (this._page && page !== this._page)
|
||||||
return;
|
return;
|
||||||
const url = network.parsedURL(request.url());
|
const url = network.parseURL(request.url());
|
||||||
if (!url)
|
if (!url)
|
||||||
return;
|
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 {
|
try {
|
||||||
return new URL(url);
|
return new URL(url);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -107,19 +107,15 @@ export function urlMatches(baseURL: string | undefined, urlString: string, match
|
|||||||
match = globToRegex(match);
|
match = globToRegex(match);
|
||||||
if (isRegExp(match))
|
if (isRegExp(match))
|
||||||
return match.test(urlString);
|
return match.test(urlString);
|
||||||
if (typeof match === 'string' && match === urlString)
|
const url = parseURL(urlString);
|
||||||
return true;
|
|
||||||
const url = parsedURL(urlString);
|
|
||||||
if (!url)
|
if (!url)
|
||||||
return false;
|
return false;
|
||||||
if (typeof match === 'string')
|
|
||||||
return url.pathname === match;
|
|
||||||
if (typeof match !== 'function')
|
if (typeof match !== 'function')
|
||||||
throw new Error('url parameter should be string, RegExp or function');
|
throw new Error('url parameter should be string, RegExp or function');
|
||||||
return match(url);
|
return match(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parsedURL(url: string): URL | null {
|
function parseURL(url: string): URL | null {
|
||||||
try {
|
try {
|
||||||
return new URL(url);
|
return new URL(url);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user