vscode-gitlink icon indicating copy to clipboard operation
vscode-gitlink copied to clipboard

Gitlab links are not working

Open mipopon opened this issue 2 years ago • 3 comments

The url structure potentially changed?

my remote uses subgroups and it looks like this https://gitlab.com/[group]/[sub-group]/[repository-name].git but the resulting link I got is https://gitlab.com/[group]/[sub-group]/blob/[branch]/path/to/file

the correct link should be https://gitlab.com/[group]/[sub-group]/[repository-name]/-/blob/[branch]/path/to/file

mipopon avatar Apr 12 '24 13:04 mipopon

+1

felipeloha avatar May 22 '25 14:05 felipeloha

The regular expressions being used to match HTTP and SSH repository strings are incorrect and can't match "deeper" GitLab URLs.

Here's a possible improvement that expands the third capture group to be "everything between the hostname and the final /":

/(https?:\/\/)(?:[^:@]+:[^:@]+@)?([^\/:]+)\/((?:[^\/:]+\/)*[^\/:]+)\/([^\/:\n]+)/

This could/should also be applied to the gitRegex regex as well. (Which itself probably shouldn't assume the username is always git since things like Dokku exist that support ssh pushes to a git remote using a different username.)

beporter avatar Aug 26 '25 01:08 beporter

Actually someone already submitted a PR: #59

beporter avatar Aug 26 '25 01:08 beporter