Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript determine if string is valid 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: #javascript #determine #string #valid #url
ADD COMMENT
Topic
Name
2+9 =