Skip to content

Commit

Permalink
fix(attachment): if a md file and attachment share a common path, it …
Browse files Browse the repository at this point in the history
…leads to an errored path

now all attachment in "allow non supported obsidian file" will be prepended by the `.` to prevent a file to be moved by error.
closes #356
  • Loading branch information
Mara-Li committed Jul 28, 2024
1 parent 4736446 commit 6b7d73b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils/data_validation_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
getProperties,
} from "src/utils/parse_frontmatter";
import merge from "ts-deepmerge";
import { escapeRegex } from "../conversion/links";

/**
* - Check if the file is a valid file to publish
Expand Down Expand Up @@ -251,11 +252,12 @@ export function isAttachment(
if (filename.match(/excalidraw\.md$/i)) return filename.match(/excalidraw\.md$/i);
if (attachmentExtern && attachmentExtern.length > 0) {
for (const att of attachmentExtern) {
const naturalExt = new RegExp(`\\.${escapeRegex(att)}$`, "i");
const isRegex = att.match(FIND_REGEX);
if (isRegex) {
const regex = isRegex ? new RegExp(isRegex[1], isRegex[2]) : null;
if (regex?.test(filename)) return filename.match(regex);
} else if (filename.match(att)) return filename.match(att);
} else if (filename.match(naturalExt)) return filename.match(naturalExt);
}
}
return filename.match(
Expand Down

0 comments on commit 6b7d73b

Please sign in to comment.