Permalink
Browse files

deal with npm:// URLs

  • Loading branch information...
1 parent c96fc63 commit 4cda04f43d172904c3ffc2b5cfce1fc5c0003fdd @othiym23 othiym23 committed May 22, 2014
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/request.js
View
@@ -1,5 +1,4 @@
module.exports = regRequest
-module.exports.toRegistryURL = toRegistryURL
var url = require("url")
, zlib = require("zlib")
@@ -12,10 +11,6 @@ var url = require("url")
, pkg = require("../package.json")
-function toRegistryURL(registry, path) {
- return url.resolve(registry, path)
-}
-
// npm: means
// 1. https
// 2. send authorization
@@ -31,6 +26,12 @@ function regRequest (method, uri, options, cb_) {
var parsed = url.parse(uri)
+ var authThis = false
+ if (parsed.protocol === "npm") {
+ parsed.protocol = "https"
+ authThis = true
+ }
+
var where = parsed.pathname
if (parsed.search) {
where = where + parsed.search
@@ -67,7 +68,7 @@ function regRequest (method, uri, options, cb_) {
, alwaysAuth = this.conf.get('always-auth')
, isDel = method === "DELETE"
, isWrite = what || isDel
- , authRequired = (alwaysAuth || isWrite) && !nu || uc || isDel
+ , authRequired = (authThis || alwaysAuth || isWrite) && !nu || uc || isDel
// resolve to a full url on the registry
if (!where.match(/^https?:\/\//)) {

0 comments on commit 4cda04f

Please sign in to comment.