File tree Expand file tree Collapse file tree 2 files changed +63
-58
lines changed
Expand file tree Collapse file tree 2 files changed +63
-58
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ function protocolToRepresentation (protocol) {
1717}
1818
1919function lastIndexOfBefore ( str , char , beforeChar ) {
20- const startPosition = str . lastIndexOf ( beforeChar )
20+ const startPosition = str . indexOf ( beforeChar )
2121 return str . lastIndexOf ( char , startPosition > - 1 ? startPosition : Infinity )
2222}
2323
@@ -193,7 +193,9 @@ const isGitHubShorthand = (arg) => {
193193
194194// attempt to correct an scp style url so that it will parse with `new URL()`
195195const correctUrl = ( giturl ) => {
196- const firstAt = giturl . indexOf ( '@' )
196+ // ignore @ that come after the first hash since the denotes the start
197+ // of a committish which can contain @ characters
198+ const firstAt = lastIndexOfBefore ( giturl , '@' , '#' )
197199 // ignore colons that come after the hash since that could include colons such as:
198200 // git@github .com:user/package-2#semver:^1.0.0
199201 const lastColonBeforeHash = lastIndexOfBefore ( giturl , ':' , '#' )
You can’t perform that action at this time.
0 commit comments