Skip to content

Commit

Permalink
fix: do not parse tarball urls for gitlab
Browse files Browse the repository at this point in the history
PR-URL: #83
Credit: @nlf
Close: #83
Reviewed-by: @wraithgar
  • Loading branch information
nlf committed Mar 24, 2021
1 parent 974bbca commit 3756d2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion git-host-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ gitHosts.gitlab = Object.assign({}, defaults, {
tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/repository/archive.tar.gz?ref=${maybeEncode(committish) || 'master'}`,
extract: (url) => {
const path = url.pathname.slice(1)
if (path.includes('/-/')) {
if (path.includes('/-/') || path.includes('/archive.tar.gz')) {
return
}

Expand Down
5 changes: 4 additions & 1 deletion test/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const invalid = [
// gitlab urls can contain a /-/ segment, make sure we ignore those
'https://gitlab.com/foo/-/something',
// missing project
'https://gitlab.com/foo'
'https://gitlab.com/foo',
// tarball, this should not parse so that it can be used for pacote's remote fetcher
'https://gitlab.com/foo/bar/repository/archive.tar.gz',
'https://gitlab.com/foo/bar/repository/archive.tar.gz?ref=49b393e2ded775f2df36ef2ffcb61b0359c194c9'
]

// assigning the constructor here is hacky, but the only way to make assertions that compare
Expand Down

0 comments on commit 3756d2f

Please sign in to comment.