Skip to content

Commit 68dc489

Browse files
Leo310claude
andcommitted
fix(views): a note link href with a percent sign is a valid path
decodeURIComponent threw on raw vault paths such as "50% off.md"; decoding is now attempted and the raw href used when it is not valid encoding. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0473651 commit 68dc489

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎src/genview/viewFrame.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,14 @@ export const VIEW_RUNTIME_SCRIPT = `
182182
const explicit = element.getAttribute("data-note");
183183
if (explicit) return explicit;
184184
const href = element.tagName === "A" ? element.getAttribute("href") : null;
185-
if (href && !NOT_A_NOTE.test(href.trim())) return decodeURIComponent(href.trim());
186-
return null;
185+
if (!href || NOT_A_NOTE.test(href.trim())) return null;
186+
// An href may be a raw vault path ("50% off.md") or a percent-encoded one; decode
187+
// only when that is valid, otherwise the raw text is the path.
188+
try {
189+
return decodeURIComponent(href.trim());
190+
} catch (error) {
191+
return href.trim();
192+
}
187193
};
188194
const noteLinkOf = (target) => {
189195
if (!target || !target.closest) return null;

0 commit comments

Comments
 (0)