Comment

Comment by salil999

In the example they have

> 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);

parent salil999 2 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton