Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 1.1.1 to 2.0.0

3

index.js
'use strict';
var htmlCommentRegex = require('html-comment-regex');

@@ -18,3 +19,3 @@ function isBinary(buf) {

module.exports = function (buf) {
return !isBinary(buf) && /<svg[^>]*>[^]*<\/svg>\s*$/.test(buf);
return !isBinary(buf) && /^\s*(?:<\?xml[^>]*>)?(?:<!doctype svg[^>]*>)?<svg[^>]*>[^]*<\/svg>\s*$/i.test(buf.toString().replace(htmlCommentRegex, ''));
};
{
"name": "is-svg",
"version": "1.1.1",
"version": "2.0.0",
"description": "Check if a String/Buffer is SVG",

@@ -10,3 +10,3 @@ "license": "MIT",

"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
"url": "sindresorhus.com"
},

@@ -17,3 +17,3 @@ "engines": {

"scripts": {
"test": "mocha"
"test": "xo && ava"
},

@@ -39,5 +39,9 @@ "files": [

],
"dependencies": {
"html-comment-regex": "^1.1.0"
},
"devDependencies": {
"mocha": "*"
"ava": "*",
"xo": "*"
}
}

@@ -8,3 +8,3 @@ # is-svg [![Build Status](https://travis-ci.org/sindresorhus/is-svg.svg?branch=master)](https://travis-ci.org/sindresorhus/is-svg)

```sh
```
$ npm install --save is-svg

@@ -17,2 +17,4 @@ ```

```js
const isSvg = require('is-svg');
isSvg('<svg xmlns="http://www.w3.org/2000/svg"><path fill="#00CD9F"/></svg>');

@@ -22,5 +24,13 @@ //=> true

## Edge cases
This module performs a quick-and-dirty check. It's fast, but in certain cases it'll give incorrect results.
- Returns `true` for an SVG-like string that isn't well-formed or valid: `<svg><div></svg>`
If you want to make certain that your SVG is *valid*, try parsing it with [libxmljs](https://github.com/polotek/libxmljs).
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)
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