ak-url-validate

1.0.4 • Public • Published

URL Validate

Build Status NPM Downloads Package Size NPM Version Contributors Commit

This library helps in validating whether a url exists or not. It verifies url pattern and whether the url is up and running.

Buy Me A Coffee Become a Patron!

Please consider donating, if you like my work

Install

npm install ak-url-validate

Usage

var auv = require('ak-url-validate');
 
const url = 'http://github.com/arshadkazmi42';
const response = await auv.isValidUrl(url);
if (response.isValid) {
  // Do something if the url is valid
} else {
  // Do something if url is invalid
}
 

Status Codes

isValid function returns status code whatever is returned from the url response. Some of the status codes are mentioned below

  • SUCCESS: This code is returned when the url is up and running.
{
  code: "SUCCESS",
  isValid: true
}
  • 404: This code is returned when the url is not found.
{
  code: 404,
  isValid: false,
  message: "Not Found"
}
  • ETIMEDOUT: This code is returned when the url is not responsding and get timed out.
{ 
  isValid: false, 
  code: "ETIMEDOUT",
  message: "Invalid Url" 
}
  • INVALID: This is an exception code, if the url does not return any status code, this code is returned in the response
{
  isValid: false, 
  code: "INVALID",
  message: "Invalid Url" 
}

Contributing Guidelines

Read the contributing guidelines here

Contributors

Package Sidebar

Install

npm i ak-url-validate

Weekly Downloads

3

Version

1.0.4

License

GPL-3.0-or-later

Unpacked Size

42.6 kB

Total Files

6

Last publish

Collaborators

  • arshadkazmi42