getRelativeFilePath fails on Windows due to case-sensitive string replacement

Open Beginner friendly
#78 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript, vscode
Domain
devtools

Research direction

Start in src/utils.ts at getRelativeFilePath and compare the current path handling with the Windows example in the issue. Reproduce the case difference if possible, then verify that the generated blame URL contains the repository-relative path rather than the full local path.

Written by the indexing model from the issue text.

Description

On Windows, commands like "Githubinator: Blame" produce URLs containing the full local file path instead of the repo-relative path:

https://github.com/user/repo/blame/<sha>/E%3A%5Cgit%5Cruntime%5Csrc%5Clibraries%5C...

instead of:

https://github.com/user/repo/blame/<sha>/src/libraries/...

Root cause: In src/utils.ts, getRelativeFilePath uses String.replace():

const resolvedFileName = fs.realpathSync(fileName)
return resolvedFileName.replace(repositoryDir.fsPath, "")

fs.realpathSync() resolves to the true filesystem casing (e.g., E:\git\runtime\...), but repositoryDir.fsPath may have different casing (e.g., e:\git\runtime\...). Since String.replace() is case-sensitive, the replacement silently fails on Windows and the entire absolute path ends up in the URL.

Suggested fix: Use path.relative() instead, which handles case and separator differences correctly on all platforms:

const resolvedFileName = fs.realpathSync(fileName)
return path.relative(repositoryDir.fsPath, resolvedFileName)
Dominant language
TypeScript
Stars
21
Forks
10
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from chdsbd/vscode-githubinator

All issues in chdsbd/vscode-githubinator

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.