schnee effeckt und fehler Korektur
This commit is contained in:
49
node_modules/is-svg/index.js
generated
vendored
49
node_modules/is-svg/index.js
generated
vendored
@@ -1,19 +1,42 @@
|
||||
'use strict';
|
||||
const {XMLParser, XMLValidator} = require('fast-xml-parser');
|
||||
|
||||
function isBinary(buf) {
|
||||
var isBuf = Buffer.isBuffer(buf);
|
||||
|
||||
for (var i = 0; i < 24; i++) {
|
||||
var charCode = isBuf ? buf[i] : buf.charCodeAt(i);
|
||||
|
||||
if (charCode === 65533 || charCode <= 8) {
|
||||
return true;
|
||||
}
|
||||
const isSvg = input => {
|
||||
if (input === undefined || input === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
input = input.toString().trim();
|
||||
|
||||
module.exports = function (buf) {
|
||||
return !isBinary(buf) && /<svg[^>]*>[^]*<\/svg>\s*$/.test(buf);
|
||||
if (input.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Has to be `!==` as it can also return an object with error info.
|
||||
if (XMLValidator.validate(input) !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let jsonObject;
|
||||
const parser = new XMLParser();
|
||||
|
||||
try {
|
||||
jsonObject = parser.parse(input);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!jsonObject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!('svg' in jsonObject)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = isSvg;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = isSvg;
|
||||
|
||||
Reference in New Issue
Block a user