From 6a0661d493d6666a4e880d68cd49ecc45ff6f8cd Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 25 Apr 2014 16:41:48 -0600 Subject: [PATCH] actually fixed addFile to allow leading '/' this time... --- ca-store-generator.js | 4 +++- package.json | 2 +- ssl-root-cas.js | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ca-store-generator.js b/ca-store-generator.js index 4cd701a..26a09ea 100644 --- a/ca-store-generator.js +++ b/ca-store-generator.js @@ -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" ); diff --git a/package.json b/package.json index a0381f0..04986d1 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/ssl-root-cas.js b/ssl-root-cas.js index c636881..8248a72 100644 --- a/ssl-root-cas.js +++ b/ssl-root-cas.js @@ -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; };