Better default request names

This commit is contained in:
Gregory Schier
2023-11-09 17:26:04 -08:00
parent 3f717d4c5a
commit 29e0b9e5d2

View File

@@ -782,10 +782,15 @@ function defaultRequestName(r: HttpRequest): string | null {
return '';
}
const fixedUrl = r.url.match(/^https?:\/\//) ? r.url : 'http://' + r.url;
try {
const url = new URL(r.url);
return url.pathname != '/' ? url.host + url.pathname : url.host;
const url = new URL(fixedUrl);
const pathname = url.pathname === '/' ? '' : url.pathname;
return `${url.host}${pathname}`;
} catch (_) {
return r.url;
// Nothing
}
return null;
}