You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
864 B
JavaScript
38 lines
864 B
JavaScript
4 years ago
|
"use strict";
|
||
|
|
||
|
const Promise = require("bluebird");
|
||
|
const fs = require("fs");
|
||
|
const path = require("path");
|
||
|
const detectSVGScripts = require("./");
|
||
|
|
||
|
Promise.try(() => {
|
||
|
return detectSVGScripts(fs.createReadStream(path.join(__dirname, "test-svg/clock.svg")));
|
||
|
}).then((result) => {
|
||
|
console.log(result); /*
|
||
|
[
|
||
|
{
|
||
|
type: 'inlineScriptTag',
|
||
|
tag: { name: 'SCRIPT', attributes: [Object], isSelfClosing: false }
|
||
|
}
|
||
|
]
|
||
|
*/
|
||
|
|
||
|
return fs.promises.readFile(path.join(__dirname, "test-svg/wpt.svg"));
|
||
|
}).then((buffer) => {
|
||
|
return detectSVGScripts(buffer);
|
||
|
}).then((result) => {
|
||
|
console.log(result); /*
|
||
|
[
|
||
|
{
|
||
|
type: 'eventHandler',
|
||
|
tag: { name: 'SVG', attributes: [Object], isSelfClosing: false },
|
||
|
attribute: 'onload'
|
||
|
},
|
||
|
{
|
||
|
type: 'inlineScriptTag',
|
||
|
tag: { name: 'SCRIPT', attributes: [Object], isSelfClosing: false }
|
||
|
}
|
||
|
]
|
||
|
*/
|
||
|
});
|