Permalink
Browse files

Improved fetching with noproxy set.

  • Loading branch information...
1 parent e501809 commit 0456a8182371888709ee5e74aa8a295985d3215e @vvision committed Nov 12, 2012
Showing with 14 additions and 27 deletions.
  1. +12 −24 lib/utils/fetch.js
  2. +2 −3 package.json
View
@@ -66,34 +66,22 @@ function makeRequest (remote, fstr, headers) {
}
var proxy = null
- , useProxy = true
- , noProxy = npm.config.get("noproxy") || "null"
- , noProxyTab = noProxy.split(",")
-
- for(var i = 0, len = noProxyTab.length; i < len; ++i) {
- noProxyTab[i] = noProxyTab[i].replace("*", "").trim()
- if(remote.hostname.indexOf(noProxyTab[i]) !== -1) {
- //Found a match between hostname and noProxy
- useProxy = false
- }
- }
-
- if(useProxy) {
- //Use of proxy authorized
+ if(npm.config.get("noproxy").search(remote.hostname) === -1) {
if (remote.protocol !== "https:" || !(proxy = npm.config.get("https-proxy"))) {
proxy = npm.config.get("proxy")
}
}
var opts = { url: remote
- , proxy: proxy
- , strictSSL: npm.config.get("strict-ssl")
- , ca: remote.host === regHost ? npm.config.get("ca") : undefined
- , headers: { "user-agent": npm.config.get("user-agent") }}
- var req = request(opts)
- req.on("error", function (er) {
- fstr.emit("error", er)
- })
- req.pipe(fstr)
- return req;
+ , proxy: proxy
+ , strictSSL: npm.config.get("strict-ssl")
+ , ca: remote.host === regHost ? npm.config.get("ca") : undefined
+ , headers: { "user-agent": npm.config.get("user-agent") }}
+
+ var req = request(opts)
+ req.on("error", function (er) {
+ fstr.emit("error", er)
+ })
+ req.pipe(fstr)
+ return req;
}
View
@@ -108,7 +108,6 @@
"opener"
],
"devDependencies": {
- "express": "2.5.9",
"ronn": "~0.3.6",
"tap": "~0.2.5"
},
@@ -117,7 +116,7 @@
"npm": "1"
},
"scripts": {
- "test": "node ./test/run.js && tap test/tap/*.js && tap test/tap/no_proxy/no_proxy_test.js",
+ "test": "node ./test/run.js && tap test/tap/*.js",
"prepublish": "npm prune ; rm -rf test/*/*/node_modules ; make -j4 doc",
"dumpconf": "env | grep npm | sort | uniq",
"echo": "node bin/npm-cli.js"
@@ -127,5 +126,5 @@
"type": "MIT +no-false-attribs",
"url": "https://github.com/isaacs/npm/raw/master/LICENSE"
}
- ]
+ ]
}

0 comments on commit 0456a81

Please sign in to comment.