diff --git a/src/helpers.ts b/src/helpers.ts index 2f26f8c..ae22037 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -1,3 +1,4 @@ +import { normalize } from "path"; /** * Finds the matching suffixes of the string, stripping off the non-matching starting characters. @@ -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 diff --git a/test/helpers.test.ts b/test/helpers.test.ts index 92914b8..3773245 100644 --- a/test/helpers.test.ts +++ b/test/helpers.test.ts @@ -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); });