Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust file name normalization #352

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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