Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to read valid url in javascript new URL()

function isValidHttpUrl(string) {
  let url;
  
  try {
    url = new URL(string);
  } catch (_) {
    return false;  
  }

  return url.protocol === "http:" || url.protocol === "https:";
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #read #valid #url #javascript
ADD COMMENT
Topic
Name
5+7 =