Skip to content

Commit 014c3a2

Browse files
committed
Use decodeURIComponent but not encodeURIComponent
1 parent 9f259df commit 014c3a2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

web_src/js/markup/anchors.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function initMarkupAnchors() {
2525
const originalId = heading.id.replace(/^user-content-/, '');
2626
const a = document.createElement('a');
2727
a.classList.add('anchor');
28-
a.setAttribute('href', `#${encodeURIComponent(originalId)}`);
28+
a.setAttribute('href', `#${decodeURIComponent(originalId)}`);
2929
a.innerHTML = svg('octicon-link');
3030
a.addEventListener('click', (e) => {
3131
scrollToAnchor(e.currentTarget.getAttribute('href'), false);
@@ -38,8 +38,8 @@ export function initMarkupAnchors() {
3838
const href = a.getAttribute('href');
3939
if (!href.startsWith('#user-content-')) continue;
4040
const originalId = href.replace(/^#user-content-/, '');
41-
a.setAttribute('href', `#${originalId}`);
42-
if (a.closest('.markup').querySelectorAll(`a[name="${originalId}"]`).length !== 1) {
41+
a.setAttribute('href', `#${decodeURIComponent(originalId)}`);
42+
if (a.closest('.markup').querySelectorAll(`a[name="${decodeURIComponent(originalId)}"]`).length !== 1) {
4343
a.addEventListener('click', (e) => {
4444
scrollToAnchor(e.currentTarget.getAttribute('href'), false);
4545
});

0 commit comments

Comments
 (0)