Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
deal with npm:// URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
othiym23 committed Jun 6, 2014
1 parent c96fc63 commit 4cda04f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/request.js
@@ -1,5 +1,4 @@
module.exports = regRequest
module.exports.toRegistryURL = toRegistryURL

var url = require("url")
, zlib = require("zlib")
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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?:\/\//)) {
Expand Down

0 comments on commit 4cda04f

Please sign in to comment.