Skip to content

BhanukaUOM/Image-URL-Validator

Repository files navigation

NPM version Build Status Downloads NPM

image-url-validator

Check if a url is an image

Checks asynchronously whether an image URL is valid or not with using HTTP HEAD.

Install

$ npm install --save image-url-validator

Usage

JavaScript

const isImageURL = require('image-url-validator').default;

// Promise
isImageURL('https://via.placeholder.com/300/09f/fff.png').then(is_image => {
    console.log(is_image) //=> true
});

isImageURL('https://github.com/BhanukaUOM/Image-Url-Validator').then(is_image => {
    console.log(is_image) //=> false
});

// Sync/Await
await isImageURL('https://via.placeholder.com/300/09f/fff.png'); //=> true

await isImageURL('https://github.com/BhanukaUOM/Image-Url-Validator'); //=> false

ES6

import isImageURL from 'image-url-validator';

// Promise
isImageURL('https://via.placeholder.com/300/09f/fff.png').then(is_image => {
    console.log(is_image) //=> true
});

isImageURL('https://github.com/BhanukaUOM/Image-Url-Validator').then(is_image => {
    console.log(is_image) //=> false
});

// Sync/Await
await isImageURL('https://via.placeholder.com/300/09f/fff.png'); //=> true

await isImageURL('https://github.com/BhanukaUOM/Image-Url-Validator'); //=> false

Release Notes

v1.0.1

  • Added ES6 Support

v0.2.0

  • Added ES5 Support

v0.0.1

  • Initial Release

License

Licensed under The MIT License (MIT)

About

NPM Package to Checks asynchronously whether an image URL is valid or not with using HTTP HEAD

Topics

Resources

Stars

Watchers

Forks