UNPKG

822 BMarkdownView Raw
1# is-svg [![Build Status](https://travis-ci.org/sindresorhus/is-svg.svg?branch=master)](https://travis-ci.org/sindresorhus/is-svg)
2
3> Check if a string or buffer is [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics)
4
5
6## Install
7
8```
9$ npm install is-svg
10```
11
12
13## Usage
14
15```js
16const isSvg = require('is-svg');
17
18isSvg('<svg xmlns="http://www.w3.org/2000/svg"><path fill="#00CD9F"/></svg>');
19//=> true
20```
21
22
23## Edge cases
24
25This module performs a quick-and-dirty check. It's fast, but in certain cases it will give incorrect results.
26
27- Returns `true` for an SVG-like string that isn't well-formed or valid: `<svg><div></svg>`
28
29If you want to make certain that your SVG is *valid*, try parsing it with [libxmljs](https://github.com/polotek/libxmljs).
30
31
32## License
33
34MIT © [Sindre Sorhus](https://sindresorhus.com)