@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
Markdown
# šø 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);
});
```