aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/lib/repo.js
diff options
context:
space:
mode:
authorTimothy J Fontaine <tjfontaine@gmail.com>2014-06-05 15:18:15 -0700
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-06-06 15:07:29 -0700
commitf051f317905b3b31945dfe965a492e54902e595f (patch)
tree06fedaefc3fc2dd5d6f197762afa4cd351659858 /deps/npm/lib/repo.js
parent535c7777ac674ba86cf93c44824e07b0e23ea8c4 (diff)
downloadandroid-node-v8-f051f317905b3b31945dfe965a492e54902e595f.tar.gz
android-node-v8-f051f317905b3b31945dfe965a492e54902e595f.tar.bz2
android-node-v8-f051f317905b3b31945dfe965a492e54902e595f.zip
npm: upgrade to v1.4.14
Diffstat (limited to 'deps/npm/lib/repo.js')
-rw-r--r--deps/npm/lib/repo.js23
1 files changed, 22 insertions, 1 deletions
diff --git a/deps/npm/lib/repo.js b/deps/npm/lib/repo.js
index b95bd7562f..a2ec99bb03 100644
--- a/deps/npm/lib/repo.js
+++ b/deps/npm/lib/repo.js
@@ -19,6 +19,7 @@ var npm = require("./npm.js")
, path = require("path")
, readJson = require("read-package-json")
, fs = require("fs")
+ , url_ = require('url')
function repo (args, cb) {
var n = args.length && args[0].split("@").shift() || '.'
@@ -40,7 +41,11 @@ function getUrlAndOpen (d, cb) {
// from https://github.com/npm/npm-www/issues/418
if (githubUserRepo(r.url))
r.url = githubUserRepo(r.url)
- var url = github(r.url)
+
+ var url = (r.url && ~r.url.indexOf('github'))
+ ? github(r.url)
+ : nonGithubUrl(r.url)
+
if (!url)
return cb(new Error('no repository: could not get url'))
opener(url, { command: npm.config.get("browser") }, cb)
@@ -52,3 +57,19 @@ function callRegistry (n, cb) {
getUrlAndOpen(d, cb)
})
}
+
+function nonGithubUrl (url) {
+ try {
+ var idx = url.indexOf('@')
+ if (idx !== -1) {
+ url = url.slice(idx+1).replace(/:([^\d]+)/, '/$1')
+ }
+ url = url_.parse(url)
+ var protocol = url.protocol === 'https:'
+ ? 'https:'
+ : 'http:'
+ return protocol + '//' + (url.host || '') +
+ url.path.replace(/\.git$/, '')
+ }
+ catch(e) {}
+}