verify-image-url 1.2.6 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -21,4 +21,8 @@ await verifyImageURL('https://example.com/example.png', { timeout: 10000 }); //
|
|
|
21
21
|
await verifyImageURL('https://prnt.sc/zrfn0r');
|
|
22
22
|
// -> { isImage: true, imageURL: 'https://image.prntscr.com/image/-ndZGuDMRfu7oDAR-fESzg.png' }
|
|
23
23
|
// This link is from og:image meta tag since prnt.sc is a site where you can upload screenshots and get the web page url from it which isn't your image link but it's in the meta tag
|
|
24
|
+
|
|
25
|
+
// Also works with SVGs
|
|
26
|
+
await verifyImageURL('https://example.com/example.svg', { allowSVG: true });
|
|
27
|
+
// -> { isImage: true, imageURL: 'https://example.com/example.svg' }
|
|
24
28
|
```
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const jsdom_1 = require("jsdom");
|
|
|
8
8
|
const is_url_1 = __importDefault(require("is-url"));
|
|
9
9
|
const image_type_1 = __importDefault(require("image-type"));
|
|
10
10
|
const got_1 = __importDefault(require("got"));
|
|
11
|
+
const is_svg_1 = __importDefault(require("is-svg"));
|
|
11
12
|
const verifyImageURL = async (url, options) => {
|
|
12
13
|
var _a;
|
|
13
14
|
const getReturnValue = (isImage = false, imageURL = url) => ({ isImage, imageURL });
|
|
@@ -32,6 +33,8 @@ const verifyImageURL = async (url, options) => {
|
|
|
32
33
|
}
|
|
33
34
|
return getReturnValue(true, meta.content);
|
|
34
35
|
}
|
|
36
|
+
else if ((options === null || options === void 0 ? void 0 : options.allowSVG) && (0, is_svg_1.default)(responseBuffer))
|
|
37
|
+
return getReturnValue(true);
|
|
35
38
|
}
|
|
36
39
|
else
|
|
37
40
|
return getReturnValue(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "verify-image-url",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A package to check if a URL is an image URL or not and also get the valid image link from it",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"got": "^11.8.2",
|
|
30
30
|
"image-type": "^4.1.0",
|
|
31
|
+
"is-svg": "^4.3.2",
|
|
31
32
|
"is-url": "^1.2.4",
|
|
32
33
|
"jsdom": "^16.4.0"
|
|
33
34
|
},
|