Better default request names

This commit is contained in:
Gregory Schier
2023-11-09 17:26:04 -08:00
parent cd841fa13a
commit 948e19b82f

View File

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