Skip to content

Commit b2f559a

Browse files
committed
fix: handle trailing slashes in relative path replacement and improve mutation parent check
1 parent d8fd81d commit b2f559a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/fetchSrc.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ async function initElements(elements) {
4545
if (pathElement) {
4646
let path =
4747
pathElement.getAttribute("path") || getPath();
48-
if (path) text = text.replaceAll("$relativePath", path);
48+
if (path) {
49+
// Remove trailing slash if present
50+
if (path.endsWith("/")) {
51+
path = path.slice(0, -1);
52+
}
53+
text = text.replaceAll("$relativePath", path);
54+
}
4955
}
5056

5157
text = text.replaceAll("ObjectId()", () => {

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,11 @@ Observer.init({
13311331
types: ["addedNodes"],
13321332
selector: "[render-clone]",
13331333
callback: function (mutation) {
1334-
if (!mutation.parentElement.hasAttribute("dnd")) return;
1334+
if (
1335+
mutation.parentElement &&
1336+
!mutation.parentElement.hasAttribute("dnd")
1337+
)
1338+
return;
13351339
let delayTimer = debounce.get(mutation);
13361340
clearTimeout(delayTimer);
13371341
debounce.delete(mutation.target);

0 commit comments

Comments
 (0)