Demo for query storing
Change-Id: I947bcac841992c3f6cfd01ab337c265b0d01cb70
diff --git a/node_modules/is-svg/index.js b/node_modules/is-svg/index.js
new file mode 100644
index 0000000..3d5cfe4
--- /dev/null
+++ b/node_modules/is-svg/index.js
@@ -0,0 +1,30 @@
+'use strict';
+const htmlCommentRegex = require('html-comment-regex');
+
+const isBinary = buffer => {
+ const isBuffer = Buffer.isBuffer(buffer);
+
+ for (let i = 0; i < 24; i++) {
+ const characterCode = isBuffer ? buffer[i] : buffer.charCodeAt(i);
+
+ if (characterCode === 65533 || characterCode <= 8) {
+ return true;
+ }
+ }
+
+ return false;
+};
+
+const cleanEntities = svg => {
+ const entityRegex = /\s*<!Entity\s+\S*\s*(?:"|')[^"]+(?:"|')\s*>/img;
+ // Remove entities
+ return svg.replace(entityRegex, '');
+};
+
+const regex = /^\s*(?:<\?xml[^>]*>\s*)?(?:<!doctype svg[^>]*\s*(?:\[?(?:\s*<![^>]*>\s*)*\]?)*[^>]*>\s*)?(?:<svg[^>]*>[^]*<\/svg>|<svg[^/>]*\/\s*>)\s*$/i;
+
+const isSvg = input => Boolean(input) && !isBinary(input) && regex.test(cleanEntities(input.toString()).replace(htmlCommentRegex, ''));
+
+module.exports = isSvg;
+// TODO: Remove this for the next major release
+module.exports.default = isSvg;