goredirects icon indicating copy to clipboard operation
goredirects copied to clipboard

Parse git URLs in a more generic way instead of tight coupling against github.com

Open skymeyer opened this issue 7 years ago • 5 comments

Fixes #3

skymeyer avatar Sep 03 '18 00:09 skymeyer

Coverage Status

Coverage remained the same at 9.649% when pulling c95fe89b0512374ebad5e2ebdc7b034804763ad4 on skymeyer:genericgit into b3920ba1acb5c1709b71e76034c05531b32205e6 on bramp:master.

coveralls avatar Sep 03 '18 00:09 coveralls

The reason it was specific to GitHub, is because I didn't think you could always assume the git and https URLs mapped like this. It seems to work for bitbucket, do you know if this mapping of URLs is part of a standard or spec?

bramp avatar Sep 03 '18 06:09 bramp

Just tested gitlab and that seems to work as well for me.

The only spec I know of is what is described in https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols. If a git server implements both ssh and https protocol it is assumed that both are served from the same hostname, so I think this generic approach should be ok.

Otherwise we can resort to creating a parser interface (supplying some defaults for github, bitbucket, gitlab, ...) and allowing injection in the redirectCreator for people having a more exotic use-case or private git servers from which we can't derive the parser from the remote URL.

skymeyer avatar Sep 03 '18 09:09 skymeyer

Thanks for researching this. Ok I'm happy with the current changes. If you wish to create a parsing/mapping interface feel free, or we could just defer that to later.

bramp avatar Sep 03 '18 12:09 bramp

I'd defer that to later yes if we have concrete short comings, I think we are good like it is for now.

skymeyer avatar Sep 04 '18 22:09 skymeyer