UNPKG

@aikidosec/firewall

Version:

Zen by Aikido is an embedded Web Application Firewall that autonomously protects Node.js apps against common and critical attacks

25 lines (24 loc) 639 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tryParseURL = void 0; let tryParseURL; exports.tryParseURL = tryParseURL = parseAndCatchError; function parseAndCatchError(url) { try { return new URL(url); } catch { return undefined; } } function canParse(url) { if (URL.canParse(url)) { return new URL(url); } return undefined; } // URL.canParse(...) is a lot faster than using the constructor and catching the error // Added in Node.js: v19.9.0, v18.17.0 if (typeof URL.canParse === "function") { exports.tryParseURL = tryParseURL = canParse; }