MCPcopy
hub / github.com/lissy93/web-check / parseTarget

Function parseTarget

api/_common/parse-target.js:11–28  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

9
10// Normalise a user-supplied target, stripping :port for DNS lookups
11export const parseTarget = (input) => {
12 if (!input) throw new Error('No target provided');
13 let normalised = /^https?:\/\//i.test(input) ? input : `https://${input}`;
14 normalised = bracketIPv6(normalised);
15 let u;
16 try {
17 u = new URL(normalised);
18 } catch {
19 throw new Error(`Invalid URL: ${input}`);
20 }
21 return {
22 hostname: u.hostname.replace(/^\[|]$/g, ''),
23 port: u.port || null,
24 protocol: u.protocol,
25 pathname: u.pathname || '/',
26 href: u.href,
27 };
28};
29
30export default parseTarget;

Callers 15

locationHandlerFunction · 0.90
dnsHandlerFunction · 0.90
mailConfigHandlerFunction · 0.90
tlsLabsHandlerFunction · 0.90
whoisHandlerFunction · 0.90
dnsHandlerFunction · 0.90
traceRouteHandlerFunction · 0.90
txtRecordHandlerFunction · 0.90
tlsConnectionHandlerFunction · 0.90
rankHandlerFunction · 0.90
portsHandlerFunction · 0.90
dnsSecHandlerFunction · 0.90

Calls 1

bracketIPv6Function · 0.85

Tested by

no test coverage detected