1.0.4 • Published 9 months ago

@mikedeni/image-url-validator v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

šŸ“ø image-url-validator

šŸ” A utility function to verify if a given URL points to a valid image by checking its content type.

šŸš€ Features

  • āœ… Validates if the URL points to a valid image.
  • 🌐 Checks content type using a HEAD request.
  • šŸ“¦ Lightweight and easy to use.

āš™ļø Installation

You can install the package via npm:

npm install @mikedeni/image-url-validator

šŸ’” Example

const isImageURL = require('@mikedeni/image-url-validator');

isImageURL('https://example.com/image.jpg')
  .then(isImage => {
    console.log(isImage ? 'The URL points to an image.' : 'The URL does not point to an image.');
  })
  .catch(error => {
    console.error('Error:', error);
  });