Skip to content

Commit

Permalink
Adjust file name normalization #351
Browse files Browse the repository at this point in the history
Co-authored-by: ryanluker <[email protected]>
Co-authored-by: agfn <[email protected]>
  • Loading branch information
ryanluker committed Dec 5, 2021
1 parent 1fa499c commit 5c5fef4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { normalize } from "path";

/**
* Finds the matching suffixes of the string, stripping off the non-matching starting characters.
Expand Down Expand Up @@ -28,7 +29,9 @@ export function findIntersect(base: string, comparee: string): string {
* @param fileName File name to remove OS specific features
*/
export function normalizeFileName(fileName: string): string {
let name = fileName;
// properly handle relative file path bits
// See #351 https://github.com/ryanluker/vscode-coverage-gutters/issues/351
let name = normalize(fileName);
// make file path relative and OS independent
name = name.toLocaleLowerCase();
// remove all file slashes
Expand Down
4 changes: 4 additions & 0 deletions test/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ suite("helper Tests", function() {
{fileName: "a/A/", expected: "a###a###"},
{fileName: "/###/", expected: "#########"},
{fileName: "\\/", expected: "######"},
{
expected: "###home###lt###projects###libfuzz###json-c###arraylist.c",
fileName: "/home/lt/projects/libfuzz/json-c/build/../arraylist.c",
},
].forEach((parameters) => {
expect(normalizeFileName(parameters.fileName)).to.equal(parameters.expected);
});
Expand Down

0 comments on commit 5c5fef4

Please sign in to comment.