The problem with new URL(), and how URL.parse() fixes thatkilianvalkhof.com 3 pointskilian2 years ago1 commentSaveHideCopy link On HNComments−salil9992yIn the example they haveconst 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);
Comments
In the example they have
Why would you need the latter part of the condition? Couldn't it just be this?