method URL.canParse
#URL.canParse(): boolean
Returns a boolean value indicating if a URL string is valid and can be parsed.
Examples #
#
// Check if an absolute URL string is valid
console.log(URL.canParse('https://example.org')); // Logs true
console.log(URL.canParse('https:://example.org')); // Logs false
// Check if a relative URL string with a base is valid
console.log(URL.canParse('/foo', 'https://example.org')); // Logs true
console.log(URL.canParse('/foo', 'https:://example.org')); // Logs false
Parameters #
Return Type #
boolean