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

Function bracketIPv6

api/_common/parse-target.js:2–8  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

1// Wrap bare IPv6 in brackets for URL parsing (2+ colons = IPv6)
2export const bracketIPv6 = (str) => {
3 const bare = str.replace(/^https?:\/\//i, '');
4 const host = bare.split('/')[0];
5 if (!host.startsWith('[') && (host.match(/:/g) || []).length >= 2)
6 return str.replace(host, `[${host}]`);
7 return str;
8};
9
10// Normalise a user-supplied target, stripping :port for DNS lookups
11export const parseTarget = (input) => {

Callers 2

normalizeUrlFunction · 0.90
parseTargetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected