Skip to content

Commit

Permalink
fix(cleanupIds): handle uri encoded references (#1880)
Browse files Browse the repository at this point in the history
  • Loading branch information
SethFalco authored Dec 10, 2023
1 parent 6a814cd commit c172c9e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugins/cleanupIds.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,11 @@ exports.fn = (_root, params) => {
}
}
for (const id of ids) {
let refs = referencesById.get(id);
const decodedId = decodeURI(id);
let refs = referencesById.get(decodedId);
if (refs == null) {
refs = [];
referencesById.set(id, refs);
referencesById.set(decodedId, refs);
}
refs.push({ element: node, name });
}
Expand Down Expand Up @@ -261,7 +262,7 @@ exports.fn = (_root, params) => {
if (value.includes('#')) {
// replace id in href and url()
element.attributes[name] = value.replace(
`#${id}`,
`#${encodeURI(id)}`,
`#${currentIdString}`
);
} else {
Expand Down
21 changes: 21 additions & 0 deletions test/plugins/cleanupIds.25.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c172c9e

Please sign in to comment.