image-url-validator
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.4 • Public • Published

    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)

    Install

    npm i image-url-validator

    DownloadsWeekly Downloads

    363

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    5.78 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar