1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-29 20:21:14 +03:00

Fix for id prefixing

This commit is contained in:
GreLI
2015-02-01 22:58:43 +03:00
parent ad538aac46
commit 54f4b33e26

View File

@ -18,7 +18,6 @@ var referencesProps = require('./_collections').referencesProps,
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
],
idPrefix = 'id-', // prefix IDs so that values like '__proto__' don't break the work
maxIDindex = generateIDchars.length - 1;
/**
@ -36,6 +35,7 @@ exports.fn = function(data, params) {
currentIDstring,
IDs = {},
referencesIDs = {},
idPrefix = 'id-', // prefix IDs so that values like '__proto__' don't break the work
hasStyleOrScript = false;
/**
@ -75,7 +75,7 @@ exports.fn = function(data, params) {
match = attr.value.match(regReferencesUrl);
if (match) {
if (referencesIDs[match[1]]) {
if (referencesIDs[idPrefix + match[1]]) {
referencesIDs[idPrefix + match[1]].push(attr);
} else {
referencesIDs[idPrefix + match[1]] = [attr];
@ -88,7 +88,7 @@ exports.fn = function(data, params) {
match = attr.value.match(regReferencesHref);
if (match) {
if (referencesIDs[match[1]]) {
if (referencesIDs[idPrefix + match[1]]) {
referencesIDs[idPrefix + match[1]].push(attr);
} else {
referencesIDs[idPrefix + match[1]] = [attr];