Skip to content

Commit

Permalink
fix: normalize paths before comparison (close: #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Jul 21, 2021
1 parent 80092f7 commit dd35f4d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/IndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class IndexGenerator {
}).compare,
)
const codes = paths
.filter(path => path !== filePath)
.filter(path => !IndexGenerator.isSamePath(path, filePath))
.map((path, index, paths) => {
const pp = parse(path)
const parsedPath: ParsedPath = {
Expand Down Expand Up @@ -223,4 +223,11 @@ export class IndexGenerator {
const relativePath = IndexGenerator.normalizePath(relative(from, to))
return relativePath.startsWith('../') ? relativePath : `./${relativePath}`
}

public static isSamePath(path1: string, path2: string): boolean {
return (
IndexGenerator.normalizePath(path1) ===
IndexGenerator.normalizePath(path2)
)
}
}

0 comments on commit dd35f4d

Please sign in to comment.