Socket
Socket
Sign inDemoInstall

is-svg

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-svg - npm Package Compare versions

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc