Package Exports
- verify-image-url
- verify-image-url/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (verify-image-url) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
verify-image-url
Verify if a URL is an image or extract the image URL from Open Graph meta tags.
Install
$ npm i verify-image-urlExample
const { verifyImageURL } = require('verify-image-url');
await verifyImageURL('https://example.com/example.png');
// -> { isImage: true, imageURL: 'https://example.com/example.png' }
// HTML page with og:image
await verifyImageURL('https://giveaway.boats');
// -> { isImage: true, imageURL: 'https://giveaway.boats/assets/logo.png' }
// Supports custom timeouts (default: 5s)
await verifyImageURL('https://example.com/example.png', { timeout: 10000 });
// Works with SVGs
await verifyImageURL('https://example.com/example.svg', { allowSVG: true });
// -> { isImage: true, imageURL: 'https://example.com/example.svg' }
// Route through a proxy
await verifyImageURL('https://example.com/example.png', { proxy: { url: 'https://proxy.example.com?url=' } });
// This sends a GET request to https://proxy.example.com?url=https://example.com/example.png
// Proxy with authentication
await verifyImageURL('https://example.com/example.png', { proxy: { url: 'https://proxy.example.com', auth: 'secret' } });
// This sends a POST request to https://proxy.example.com with the JSON body `{ method: 'GET', url: 'https://example.com/example.png' }` along with Authorization header set to 'secret'