Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,22 @@ describe('transformLinks plugin', () => {
});
});
});

it('does not transform link to a directory with a dot in its name', async () => {
const result = await processContent(
`[link](../directory-with.dot/)`,
);
expect(result).toMatchInlineSnapshot(
`"[link](../directory-with.dot/)"`,
);
});

it('does not transform link to a directory with a dot (no trailing slash)', async () => {
const result = await processContent(
`[link](../directory-with.dot)`,
);
expect(result).toMatchInlineSnapshot(
`"[link](../directory-with.dot)"`,
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ async function processLinkNode(target: Target, context: Context) {
);

if (localFilePath) {
// Skip asset transformation for directories (e.g., "directory-with.dot/")
// A directory path with a dot can match hasAssetLikeExtension, but it
// should not be treated as a file asset — it's a valid link target.
const stats = await fs.stat(localFilePath);
if (stats.isDirectory()) {
return;
}
await toAssetRequireNode(target, localFilePath, context);
} else {
// The @site alias is the only way to believe that the user wants an asset.
Expand Down