Skip to content

Commit bbc7ef6

Browse files
committed
Remove relative path support
1 parent ebd4a28 commit bbc7ef6

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/plugins/remark/validate-images.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,17 @@ export default function validateImages() {
2323
return (tree: Node, file: VFile) => {
2424
visit(tree, "image", (node: ImageNode) => {
2525
const { url } = node;
26-
let fullPath: string | null;
26+
let fullPath: string;
2727

28-
// Skip remote images
29-
if (url.startsWith("http:") || url.startsWith("https:")) {
30-
return;
31-
}
32-
33-
// Handle relative paths to assets
34-
if (url.startsWith("../") || url.startsWith("~/assets/")) {
35-
// Remove the ~/assets/ or ../ prefix and join with the assets directory
36-
const relativePath = url.startsWith("~/") ? url.slice(9) : url;
37-
fullPath = join(assetsDir, relativePath);
28+
if (url.startsWith("~/assets/")) {
29+
fullPath = join(assetsDir, url.slice(9));
3830
} else if (url.startsWith("/")) {
39-
// Handle absolute paths (public directory)
4031
fullPath = join(publicDir, url);
4132
} else {
42-
// Skip if we don't know how to handle this URL
33+
// Remote image or unrecognised URL
4334
return;
4435
}
4536

46-
// Check if the file exists
4737
if (!existsSync(fullPath)) {
4838
const position = node.position
4939
? ` at line ${node.position.start.line}, column ${node.position.start.column}`

0 commit comments

Comments
 (0)