mirror of
https://github.com/svg/svgo.git
synced 2025-07-31 07:44:22 +03:00
Fix for id prefixing
This commit is contained in:
@ -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',
|
||||||
'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;
|
maxIDindex = generateIDchars.length - 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,6 +35,7 @@ exports.fn = function(data, params) {
|
|||||||
currentIDstring,
|
currentIDstring,
|
||||||
IDs = {},
|
IDs = {},
|
||||||
referencesIDs = {},
|
referencesIDs = {},
|
||||||
|
idPrefix = 'id-', // prefix IDs so that values like '__proto__' don't break the work
|
||||||
hasStyleOrScript = false;
|
hasStyleOrScript = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +75,7 @@ exports.fn = function(data, params) {
|
|||||||
match = attr.value.match(regReferencesUrl);
|
match = attr.value.match(regReferencesUrl);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
if (referencesIDs[match[1]]) {
|
if (referencesIDs[idPrefix + match[1]]) {
|
||||||
referencesIDs[idPrefix + match[1]].push(attr);
|
referencesIDs[idPrefix + match[1]].push(attr);
|
||||||
} else {
|
} else {
|
||||||
referencesIDs[idPrefix + match[1]] = [attr];
|
referencesIDs[idPrefix + match[1]] = [attr];
|
||||||
@ -88,7 +88,7 @@ exports.fn = function(data, params) {
|
|||||||
match = attr.value.match(regReferencesHref);
|
match = attr.value.match(regReferencesHref);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
if (referencesIDs[match[1]]) {
|
if (referencesIDs[idPrefix + match[1]]) {
|
||||||
referencesIDs[idPrefix + match[1]].push(attr);
|
referencesIDs[idPrefix + match[1]].push(attr);
|
||||||
} else {
|
} else {
|
||||||
referencesIDs[idPrefix + match[1]] = [attr];
|
referencesIDs[idPrefix + match[1]] = [attr];
|
||||||
|
Reference in New Issue
Block a user