fix(reference): preserve directory intent through portable target rebasing

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
N0zoM1z0andgensokyo-dev authored and gensokyo-dev committed 2026-11-11 16:52:07 +08:00
1 parent 8e11a430cf
commit 1f2a869e5b
3 files changed
+35 -1

No files matched your search

@@ -75,3 +75,12 @@ export const decodeReferenceSourceModuleUrlPath = (
);
}
};
/** Rebase a portable target without discarding its directory-required suffix. */
export const rebaseReferenceSourceTarget = (
linkPath: string,
target: string,
): string => {
const relative = posix.relative(posix.dirname(linkPath), target) || ".";
return target.endsWith("/") ? `${relative}/` : relative;
};