Socket
Socket
Sign inDemoInstall

is-svg

Package Overview
Dependencies
Maintainers
1
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 4.4.0 to 5.0.0

32

index.d.ts

@@ -1,24 +0,12 @@

declare const isSvg: {
/**
Check if a string or buffer is [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics).
/**
Check if a string is [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics).
@param input - The data to check.
@returns Whether `input` is SVG or not.
@example
```
import isSvg from 'is-svg';
@example
```
import isSvg = require('is-svg');
isSvg('<svg xmlns="http://www.w3.org/2000/svg"><path fill="#00CD9F"/></svg>');
//=> true
```
*/
(input: string | Buffer): boolean;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function isSvg(input: string | Buffer): boolean;
// export = isSvg;
default: typeof isSvg;
};
export = isSvg;
isSvg('<svg xmlns="http://www.w3.org/2000/svg"><path fill="#00CD9F"/></svg>');
//=> true
```
*/
export default function isSvg(string: string): boolean;

@@ -1,12 +0,11 @@

'use strict';
const {XMLParser, XMLValidator} = require('fast-xml-parser');
import {XMLParser, XMLValidator} from 'fast-xml-parser';
const isSvg = input => {
if (input === undefined || input === null) {
return false;
export default function isSvg(string) {
if (typeof string !== 'string') {
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
}
input = input.toString().trim();
string = string.trim();
if (input.length === 0) {
if (string.length === 0) {
return false;

@@ -16,3 +15,3 @@ }

// Has to be `!==` as it can also return an object with error info.
if (XMLValidator.validate(input) !== true) {
if (XMLValidator.validate(string) !== true) {
return false;

@@ -25,4 +24,4 @@ }

try {
jsonObject = parser.parse(input);
} catch (_) {
jsonObject = parser.parse(string);
} catch {
return false;

@@ -40,6 +39,2 @@ }

return true;
};
module.exports = isSvg;
// TODO: Remove this for the next major release
module.exports.default = isSvg;
}
{
"name": "is-svg",
"version": "4.4.0",
"description": "Check if a string or buffer is SVG",
"version": "5.0.0",
"description": "Check if a string is SVG",
"license": "MIT",

@@ -13,4 +13,9 @@ "repository": "sindresorhus/is-svg",

},
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"engines": {
"node": ">=6"
"node": ">=14.16"
},

@@ -29,4 +34,2 @@ "scripts": {

"image",
"img",
"pic",
"picture",

@@ -37,5 +40,3 @@ "type",

"is",
"string",
"str",
"buffer"
"string"
],

@@ -46,8 +47,8 @@ "dependencies": {

"devDependencies": {
"@types/node": "^11.13.0",
"ava": "^1.4.1",
"time-span": "^4.0.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"@types/node": "^18.14.2",
"ava": "^5.2.0",
"time-span": "^5.1.0",
"tsd": "^0.25.0",
"xo": "^0.53.1"
}
}
# is-svg
> Check if a string or buffer is [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics)
> Check if a string is [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics)
## Install
```sh
npm install is-svg
```
$ npm install is-svg
```

@@ -14,3 +14,3 @@ ## Usage

```js
const isSvg = require('is-svg');
import isSvg from 'is-svg';

@@ -20,13 +20,1 @@ isSvg('<svg xmlns="http://www.w3.org/2000/svg"><path fill="#00CD9F"/></svg>');

```
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-is-svg?utm_source=npm-is-svg&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>

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