Skip to content

Commit d1eeeeb

Browse files
committed
feat: Add slash to alias and aliasPath
This commit modifies the loop over aliases to ensure that both the alias and the aliasPath have a trailing slash. This is done by introducing a new function, addSlash, which appends a slash to a string if it does not already end with one. This change ensures consistent formatting of aliases and their paths.
1 parent 325505d commit d1eeeeb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mod.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ async function getAbsPath(
4747
return path.resolve(dirname, file);
4848
}
4949

50-
for (const [_alias, aliasPath] of Object.entries(aliases)) {
51-
const alias = _alias.endsWith("/") ? _alias : `${_alias}/`;
50+
for (const [_alias, _aliasPath] of Object.entries(aliases)) {
51+
const addSlash = (str: string) => (str.endsWith("/") ? str : `${str}/`);
52+
const alias = addSlash(_alias);
53+
const aliasPath = addSlash(_aliasPath);
5254
if (file.startsWith(alias)) {
5355
const s = new MagicString(file);
5456
s.overwrite(0, alias.length, aliasPath);

0 commit comments

Comments
 (0)