actually fixed addFile to allow leading '/' this time...

This commit is contained in:
AJ ONeal 2014-04-25 16:41:48 -06:00
parent cbc33c3578
commit 6a0661d493
3 changed files with 7 additions and 3 deletions

View File

@ -138,8 +138,10 @@ function dumpCerts(certs) {
+ "module.exports.addFile = function (filepath) {\n"
+ " var opts = require('https').globalAgent.options;\n"
+ " var root = filepath[0] === '/' ? '/' : '';\n"
+ " var filepaths = filepath.split(/\\//g);\n"
+ " if (root) { filepaths.unshift(root); }\n"
+ " opts.ca = opts.ca || [];\n"
+ " opts.ca.push(require('fs').readFileSync(require('path').join.apply(null, (root + filepath).split(/\\//g))));\n"
+ " opts.ca.push(require('fs').readFileSync(require('path').join.apply(null, filepaths)));\n"
+ " return module.exports;\n"
+ "};\n"
);

View File

@ -1,6 +1,6 @@
{
"name": "ssl-root-cas",
"version": "1.1.1",
"version": "1.1.2",
"description": "The module you need to solve node's SSL woes when including a custom certificate.",
"main": "ssl-root-cas",
"scripts": {

View File

@ -4104,7 +4104,9 @@ module.exports.inject = function () {
module.exports.addFile = function (filepath) {
var opts = require('https').globalAgent.options;
var root = filepath[0] === '/' ? '/' : '';
var filepaths = filepath.split(/\//g);
if (root) { filepaths.unshift(root); }
opts.ca = opts.ca || [];
opts.ca.push(require('fs').readFileSync(require('path').join.apply(null, (root + filepath).split(/\//g))));
opts.ca.push(require('fs').readFileSync(require('path').join.apply(null, filepaths)));
return module.exports;
};