bugthesystem / vscode-open-in-github

Extension for Visual Studio Code which can be used to jump to a source code line in Github, Bitbucket, GitLab and Visualstudio.com
MIT License
198 stars 73 forks source link

Link to subgroups on gitlab.com gives 404 #134

Open jonaskello opened 2 years ago

jonaskello commented 2 years ago

In gitlab you can have a subgroup which makes the URL longer.

For example lets say we have groupa and under it a subgroup groupb. So it becomes groupa/groupb. Then the URL for a file in the repo/project project1 that lives in groupb would become something like this:

https://gitlab.com/groupa/groupb/project1/blob/xxxxx/path/to/source/file#L123

However the plugin adds an extra /git in front of the url so it becomes:

https://gitlab.com/git/groupa/groupb/project1/blob/xxxxx/path/to/source/file#L123

This results in a 404. Removing the /git prefix gives the correct page.

tortis commented 2 years ago

I'm getting this as well. I thought it might be a problem with the version of git-url-parse package that's being used. I wrote a test script and tried it with v11.1.1 (and a few other versions) of git-url-parse, but it never produced a url with /git

const gitUrlParse = require('git-url-parse');

const remote = 'git@gitlab.myorg.com:dev/group/project.git';
const gitUrl = gitUrlParse(remote);
const url = gitUrl.toString('https').replace(/(\.git)$/, '');
console.log('url:', url);

This produces https://gitlab.myorg.com/dev/group/project without the extra /git.

So maybe it has to do with the remote url that's getting passed into get-url-parse?