Comparing version 2.1.0 to 3.0.0
14
index.js
'use strict'; | ||
var htmlCommentRegex = require('html-comment-regex'); | ||
const htmlCommentRegex = require('html-comment-regex'); | ||
function isBinary(buf) { | ||
var isBuf = Buffer.isBuffer(buf); | ||
const isBuf = Buffer.isBuffer(buf); | ||
for (var i = 0; i < 24; i++) { | ||
var charCode = isBuf ? buf[i] : buf.charCodeAt(i); | ||
for (let i = 0; i < 24; i++) { | ||
const charCode = isBuf ? buf[i] : buf.charCodeAt(i); | ||
@@ -18,4 +18,4 @@ if (charCode === 65533 || charCode <= 8) { | ||
module.exports = function (buf) { | ||
return !isBinary(buf) && /^\s*(?:<\?xml[^>]*>\s*)?(?:<!doctype svg[^>]*\s*(?:<![^>]*>)*[^>]*>\s*)?<svg[^>]*>[^]*<\/svg>\s*$/i.test(buf.toString().replace(htmlCommentRegex, '')); | ||
}; | ||
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, '')); |
{ | ||
"name": "is-svg", | ||
"version": "2.1.0", | ||
"description": "Check if a string or buffer is SVG", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-svg", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"svg", | ||
"vector", | ||
"graphics", | ||
"image", | ||
"img", | ||
"pic", | ||
"picture", | ||
"type", | ||
"detect", | ||
"check", | ||
"is", | ||
"string", | ||
"str", | ||
"buffer" | ||
], | ||
"dependencies": { | ||
"html-comment-regex": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "^0.16.0" | ||
} | ||
"name": "is-svg", | ||
"version": "3.0.0", | ||
"description": "Check if a string or buffer is SVG", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-svg", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"svg", | ||
"vector", | ||
"graphics", | ||
"image", | ||
"img", | ||
"pic", | ||
"picture", | ||
"type", | ||
"detect", | ||
"check", | ||
"is", | ||
"string", | ||
"str", | ||
"buffer" | ||
], | ||
"dependencies": { | ||
"html-comment-regex": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
} |
# is-svg [![Build Status](https://travis-ci.org/sindresorhus/is-svg.svg?branch=master)](https://travis-ci.org/sindresorhus/is-svg) | ||
> Check if a string or buffer is [SVG](http://en.wikipedia.org/wiki/Scalable_Vector_Graphics) | ||
> Check if a string or buffer is [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) | ||
@@ -9,3 +9,3 @@ | ||
``` | ||
$ npm install --save is-svg | ||
$ npm install is-svg | ||
``` | ||
@@ -12,0 +12,0 @@ |
Sorry, the diff of this file is not supported yet
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
3141
14