npm-package-arg
Advanced tools
Comparing version 5.0.1 to 5.1.0
33
npa.js
@@ -195,2 +195,18 @@ 'use strict' | ||
function matchGitScp (spec) { | ||
// git ssh specifiers are overloaded to also use scp-style git | ||
// specifiers, so we have to parse those out and treat them special. | ||
// They are NOT true URIs, so we can't hand them to `url.parse`. | ||
// | ||
// This regex looks for things that look like: | ||
// git+ssh://git@my.custom.git.com:username/project.git#deadbeef | ||
// | ||
// ...and various combinations. The username in the beginning is *required*. | ||
const matched = spec.match(/^git\+ssh:\/\/((?:[^@]+)@(?:[^:/]+):[/]?(?:(?:[^/]+[/])?[^/]+?)(?:[.]git)?)(?:#(.*))?$/i) | ||
return matched && { | ||
fetchSpec: matched[1], | ||
gitCommittish: matched[2] | ||
} | ||
} | ||
function fromURL (res) { | ||
@@ -207,11 +223,16 @@ if (!url) url = require('url') | ||
case 'git+ftp:': | ||
case 'git+file:': | ||
case 'git+ssh:': | ||
case 'git+file:': | ||
res.type = 'git' | ||
setGitCommittish(res, urlparse.hash != null ? urlparse.hash.slice(1) : '') | ||
urlparse.protocol = urlparse.protocol.replace(/^git[+]/, '') | ||
delete urlparse.hash | ||
res.fetchSpec = url.format(urlparse) | ||
const match = urlparse.protocol === 'git+ssh:' && matchGitScp(res.rawSpec) | ||
if (match) { | ||
res.fetchSpec = match.fetchSpec | ||
res.gitCommittish = match.gitCommittish | ||
} else { | ||
setGitCommittish(res, urlparse.hash != null ? urlparse.hash.slice(1) : '') | ||
urlparse.protocol = urlparse.protocol.replace(/^git[+]/, '') | ||
delete urlparse.hash | ||
res.fetchSpec = url.format(urlparse) | ||
} | ||
break | ||
case 'http:': | ||
@@ -218,0 +239,0 @@ case 'https:': |
{ | ||
"name": "npm-package-arg", | ||
"version": "5.0.1", | ||
"version": "5.1.0", | ||
"description": "Parse the things that can be arguments to `npm install`", | ||
@@ -5,0 +5,0 @@ "main": "npa.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
245
13260
4