Julius MarmingeShare safe URL diagnostics52701264 months agoHistory
19 lines · 417 B · TypeScript
RawDownload
export interface UrlDiagnostics {  readonly inputLength: number;  readonly protocol?: string;  readonly hostname?: string;} export function getUrlDiagnostics(input: string): UrlDiagnostics {  const inputLength = input.length;  try {    const url = new URL(input);    return {      inputLength,      protocol: url.protocol,      hostname: url.hostname,    };  } catch {    return { inputLength };  }}