diff --git a/__tests__/Util-test.js b/__tests__/Util-test.js index 985d05bd..932185ca 100644 --- a/__tests__/Util-test.js +++ b/__tests__/Util-test.js @@ -26,8 +26,8 @@ describe('Util', function () { expect(util.removeSensitiveData(testdata).indexOf('/Users//')).toNotEqual(-1); testdata = String.raw`/Users/some.wei-rdUsername/.docker/machine/machines/dev2/id_rsa docker@localhost echo`; - expect(util.removeSensitiveData(testdata).indexOf('/Users/some.wei-rdUsername/')).toEqual(-1); - expect(util.removeSensitiveData(testdata).indexOf('/Users//')).toNotEqual(-1); + expect(util.removeSensitiveData(testdata).indexOf('/Users/some.wei-rdUsername/.docker')).toEqual(-1); + expect(util.removeSensitiveData(testdata).indexOf('/Users//.docker')).toNotEqual(-1); }); it ('returns input if empty or not a string', function () { diff --git a/src/utils/Util.js b/src/utils/Util.js index c2830592..8d90f741 100644 --- a/src/utils/Util.js +++ b/src/utils/Util.js @@ -59,7 +59,7 @@ module.exports = { } return str.replace(/-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----/mg, '') .replace(/-----BEGIN RSA PRIVATE KEY-----.*-----END RSA PRIVATE KEY-----/mg, '') - .replace(/\/Users\/.*\//mg, '/Users//'); + .replace(/\/Users\/[^\/]*\//mg, '/Users//'); }, packagejson: function () { return JSON.parse(fs.readFileSync(path.join(__dirname, '../..', 'package.json'), 'utf8'));