Files
web-check/api/_common/parse-target.js
Alicia Sykes 6ae6b25d45 fix: Vercel Node 20 deploy, and sec visibility
- Fixes Vercel deployment by pinning to 20.x
- Refactors console outputs into logger.js
- Fixes sections still visible when no data (Server Info)
- Fixes checks still show error after fallback succeeds (Screenshot)
- Updates client-side env var names, from `REACT_APP_` to `PUBLIC_`
2026-05-04 15:59:07 +01:00

18 lines
517 B
JavaScript

// Normalise a user-supplied target, stripping :port for DNS lookups.
export const parseTarget = (input) => {
if (!input) throw new Error('No target provided');
const normalised = /^https?:\/\//i.test(input) ? input : `https://${input}`;
let u;
try { u = new URL(normalised); }
catch { throw new Error(`Invalid URL: ${input}`); }
return {
hostname: u.hostname,
port: u.port || null,
protocol: u.protocol,
pathname: u.pathname || '/',
href: u.href,
};
};
export default parseTarget;