Skip to content

getRelativeFilePath fails on Windows due to case-sensitive string replacement #78

@danmoseley

Description

@danmoseley

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions