UNPKG

@mikedeni/image-url-validator

Version:

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

26 lines (22 loc) • 720 B
# šŸ“ø 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: ```bash npm install @mikedeni/image-url-validator ``` ## šŸ’” Example ```js 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); }); ```