Comparing version 3.0.0 to 4.0.0
15
index.js
'use strict'; | ||
const htmlCommentRegex = require('html-comment-regex'); | ||
function isBinary(buf) { | ||
const isBuf = Buffer.isBuffer(buf); | ||
const isBinary = buffer => { | ||
const isBuffer = Buffer.isBuffer(buffer); | ||
for (let i = 0; i < 24; i++) { | ||
const charCode = isBuf ? buf[i] : buf.charCodeAt(i); | ||
const characterCode = isBuffer ? buffer[i] : buffer.charCodeAt(i); | ||
if (charCode === 65533 || charCode <= 8) { | ||
if (characterCode === 65533 || characterCode <= 8) { | ||
return true; | ||
@@ -16,6 +16,9 @@ } | ||
return false; | ||
} | ||
}; | ||
const regex = /^\s*(?:<\?xml[^>]*>\s*)?(?:<!doctype svg[^>]*\s*(?:\[?(?:\s*<![^>]*>\s*)*\]?)*[^>]*>\s*)?<svg[^>]*>[^]*<\/svg>\s*$/i; | ||
module.exports = input => Boolean(input) && !isBinary(input) && regex.test(input.toString().replace(htmlCommentRegex, '')); | ||
const isSvg = input => Boolean(input) && !isBinary(input) && regex.test(input.toString().replace(htmlCommentRegex, '')); | ||
module.exports = isSvg; | ||
module.exports.default = isSvg; |
{ | ||
"name": "is-svg", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Check if a string or buffer is SVG", | ||
@@ -13,9 +13,10 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
"test": "xo && ava && tsd-check" | ||
}, | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
@@ -42,5 +43,7 @@ "keywords": [ | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
"@types/node": "^11.10.4", | ||
"ava": "^1.2.1", | ||
"tsd-check": "^0.3.0", | ||
"xo": "^0.24.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3607
5
24
4