mirror of
https://github.com/Lissy93/web-check.git
synced 2026-05-12 21:00:38 -04:00
- 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_`
18 lines
517 B
JavaScript
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;
|