URL Utilities

isIP & isFQDN

Check if a URL hostname is IP or FQDN.

import {isFQDN, isIP} from 'ngx-lift';

console.log(isFQDN('www.example.com')); // true
console.log(isFQDN('192.168.0.1')); // false

console.log(isIP('www.example.com')); // false
console.log(isIP('192.168.0.1')); // true
import {isFQDN} from 'ngx-lift';

try {
  const hostname = new URL('your-url').hostname;

  if (isFQDN(hostname)) {
    // the rest of your logic
  }
} catch (error) {
  // your-url is invalid
  console.error(error);
}

isUrl & isHttps

isUrl is used to check if a URL is Valid. isHttps is used to check if the URL starts with https.

import {isHttps, isURL} from 'ngx-lift';

console.log(isURL('http://www.example.com')); // true
console.log(isHttps('https://192.168.0.1')); // true