The problem with new URL(), and how URL.parse() fixes that(kilianvalkhof.com)
kilianvalkhof.com
The problem with new URL(), and how URL.parse() fixes that
https://kilianvalkhof.com/2024/javascript/the-problem-with-new-url-and-how-url-parse-fixes-that/
> const urlstring = "this is not a URL";
> const not_a_url = URL.canParse(urlstring) && new URL(urlstring);
Why would you need the latter part of the condition? Couldn't it just be this?
> const isValidURL = URL.canParse(urlstring);