The value to validate
Type predicate indicating if the value is a valid URL
isFullURL("https://www.google.com") // Returns true
isFullURL("not a url") // Returns false
export function isFullURL(val: unknown): val is URL {
try {
new URL(String(val));
return true;
} catch {
return false;
}
}
Type guard to validate if a value is a full URL. Attempts to construct a URL object from the value.