Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript url check

const isAbsoluteUrl = url => /^[a-z][a-z0-9+.-]*:/.test(url);

// Example
isAbsoluteUrl('https://1loc.dev');          // true
isAbsoluteUrl('https://1loc.dev/foo/bar');  // true
isAbsoluteUrl('1loc.dev');                  // false
isAbsoluteUrl('//1loc.dev'); 
Comment

javascript is url

function isWebUrl(string) {
  let url;
  try {
    url = new URL(string);
  } catch (_) {
    return false;  
  }
  return url.protocol === "http:" || url.protocol === "https:";
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: react build command 
Javascript :: jquery use variable in string 
Javascript :: process.env 
Javascript :: react router base url 
Javascript :: javascript array any 
Javascript :: siwtch case javascript 
Javascript :: randomize an array in javascript 
Javascript :: how to emty an array in javascript 
Javascript :: remove duplicates from array in javascript 
Javascript :: how to use put to request in nodejs 
Javascript :: get total width of element including padding and border using jquery 
Javascript :: iso 8601 date to Js date 
Javascript :: javascript object instead of switch 
Javascript :: javascript copy content of one div to another 
Javascript :: vue 3 router redirect 
Javascript :: rotate array by d elements javascript 
Javascript :: how to insert an item into an array at a specific index in javascript 
Javascript :: Rounding Up To The Nearest Hundred js 
Javascript :: react native font based on viewport dimensions 
Javascript :: prototype in javascript 
Javascript :: dynamic navigation with subitems 
Javascript :: get list of all attributes jqery 
Javascript :: how to use js console log 
Javascript :: mobile number validation in javascript with country code 
Javascript :: min heap javascript 
Javascript :: moment get month short name 
Javascript :: Configure the Chrome debugger react 
Javascript :: bitfield permissions discord,.js 
Javascript :: jquery get tr value 
Javascript :: aggregate mongodb 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =