Skip to content

Commit

Permalink
fix(resolveAlias): preserve relative paths as is
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 6, 2022
1 parent 7471347 commit f3e5bcc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { normalize, join } from './path'
import { join } from './path'
import { normalizeWindowsPath } from './_internal'

const pathSeparators = ['/', '\\', undefined]

Expand Down Expand Up @@ -27,7 +28,7 @@ export function normalizeAliases (_aliases: Record<string, string>) {
}

export function resolveAlias (path: string, aliases: Record<string, string>) {
const _path = normalize(path)
const _path = normalizeWindowsPath(path)
aliases = normalizeAliases(aliases)
for (const alias in aliases) {
if (_path.startsWith(alias)) {
Expand Down
1 change: 1 addition & 0 deletions test/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('alias', () => {
}
it('unchanged', () => {
expect(resolveAlias('foo/bar.js', aliases)).toBe('foo/bar.js')
expect(resolveAlias('./bar.js', aliases)).toBe('./bar.js')
})
})
})
Expand Down

0 comments on commit f3e5bcc

Please sign in to comment.