Update GIT_RE regex to match on SSH urls with spaces in Project/Repo Names #75
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #IonicaBizau/git-url-parse#162
Edit - I made a silly mistake. I didn't realize #72 was already opened when I ran off and did this. I am handling one extra thing non encoded whitespace in this change. Open to suggestions on how to handle
I am trying to use
git-parse-url
and noticing it is failing for Azure DevOps (visual studio) ssh urls where there is a space in the project/repo names.I traced the bug back to this part of the logic
In this PR I updated the REGEX to allow match on whitespace characters + encoding characters within the path section
const GIT_RE = /^(?:([a-z_][a-z0-9_-]{0,31})@|https?:\/\/)([\w\.\-@]+)[\/:](([\~,\.\w,\-,\_,\/,\s]|%[0-9A-Fa-f]{2})+?(?:\.git|\/)?)$/;
The part that changed was the path capture group:
(([\~,\.\w,\-,\_,\/,\s]|%[0-9A-Fa-f]{2})+?(?:\.git|\/)?)
\s
was added to the character list to support white spaces|%[0-9A-Fa-f]{2}
to support encodingsChanges