mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
11 lines
294 B
TypeScript
11 lines
294 B
TypeScript
export function formatUrlForDiagnostics(value: string | URL): string {
|
|
const url = typeof value === 'string' ? URL.parse(value) : value;
|
|
if (!url) {
|
|
return '[invalid URL]';
|
|
}
|
|
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
return '[non-HTTP URL]';
|
|
}
|
|
return url.origin;
|
|
}
|