Compare commits

...

1 Commits

Author SHA1 Message Date
Shelley Vohr
31a2b36e08 refactor: use WHATWG URL instead of url.parse 2026-01-29 09:46:49 +01:00
3 changed files with 5 additions and 6 deletions

View File

@@ -253,7 +253,7 @@ async function startRepl () {
if (option.file && !option.webdriver) {
const file = option.file;
// eslint-disable-next-line n/no-deprecated-api
const protocol = url.parse(file).protocol;
const protocol = URL.canParse(file) ? new URL(file).protocol : null;
const extension = path.extname(file);
if (protocol === 'http:' || protocol === 'https:' || protocol === 'file:' || protocol === 'chrome:') {
await loadApplicationByURL(file);

View File

@@ -227,8 +227,7 @@ function validateHeader (name: any, value: any): void {
}
function parseOptions (optionsIn: ClientRequestConstructorOptions | string): NodeJS.CreateURLLoaderOptions & ExtraURLLoaderOptions {
// eslint-disable-next-line n/no-deprecated-api
const options: any = typeof optionsIn === 'string' ? url.parse(optionsIn) : { ...optionsIn };
const options: any = typeof optionsIn === 'string' ? new URL(optionsIn) : { ...optionsIn };
let urlStr: string = options.url;
@@ -260,8 +259,8 @@ function parseOptions (optionsIn: ClientRequestConstructorOptions | string): Nod
// an invalid request.
throw new TypeError('Request path contains unescaped characters');
}
// eslint-disable-next-line n/no-deprecated-api
const pathObj = url.parse(options.path || '/');
const pathObj = new URL(options.path || '/');
urlObj.pathname = pathObj.pathname;
urlObj.search = pathObj.search;
urlObj.hash = pathObj.hash;

View File

@@ -9,7 +9,7 @@
}
}
const parsedURL = new URL(window.location.href);
if (parsedURL.searchParams.get('opened') != null) {
if (parsedURL.searchParams.has('opened')) {
// Ensure origins are properly checked by removing a single character from the end
tryPostMessage('do not deliver substring origin', window.location.origin.substring(0, window.location.origin.length - 1))
tryPostMessage('do not deliver file://', 'file://')