New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

validate-image-url

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validate-image-url

Checks asynchronously whether an image URL is valid or not.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Validate Image URL

NPM Version Build Status Test Coverage Dependencies devDependencies
js-standard-style

Checks asynchronously whether an image URL is valid or not.

By default, if an image URL is invalid, the browser would show the following image:
before
In that case, you might want show a different image such as:
after

This package tells you whether the image URL is valid or not.

Installation:

$ npm install --save validate-image-url

Usage:

import validator from 'validate-image-url'

const promise = validator({url: '<image-url>', timeout: 10000})
  .then(({image, url}) => {
    console.log('Image URL is valid.', 'URL:', url, 'image:', image)
  })
  .catch((err) => {
    console.error('Invalid image URL or image could not be fetched within 10000 milliseconds.', 'error:', err)
  })
  
  // NOTE: the promise can be canceled by calling 
  // promise.cancel()

Options:

  • url - (required) image URL.
  • timeout - (optional) timeout in milliseconds before canceling request and rejecting the promise. Default: 5000 milliseconds.

License

MIT

Author

Oron Nadiv (oron@nadiv.us)

Keywords

image

FAQs

Package last updated on 29 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts