diff --git a/lib/utils.js b/lib/utils.js index a6a74540d9..c5fa83ad24 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -597,7 +597,7 @@ exports.stackTraceFilter = function () { // Clean up cwd(absolute) if (/\(?.+:\d+:\d+\)?$/.test(line)) { - line = line.replace(cwd, ''); + line = line.replace('(' + cwd, '('); } list.push(line); diff --git a/test/node-unit/stack-trace-filter.spec.js b/test/node-unit/stack-trace-filter.spec.js index 23cfcd8527..08cc3af03e 100644 --- a/test/node-unit/stack-trace-filter.spec.js +++ b/test/node-unit/stack-trace-filter.spec.js @@ -88,6 +88,23 @@ describe('stackTraceFilter()', function () { expect(filter(stack.join('\n'))) .to.equal(expected.join('\n')); }); + + it('should not replace absolute path which has cwd as infix', function () { + var stack = [ + 'Error: /www' + process.cwd() + '/bla.js has a problem', + 'at foo (/www' + process.cwd() + '/foo/index.js:13:226)', + 'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)' + ]; + + var expected = [ + 'Error: /www' + process.cwd() + '/bla.js has a problem', + 'at foo (/www' + process.cwd() + '/foo/index.js:13:226)', + 'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)' + ]; + + expect(filter(stack.join('\n'))) + .to.equal(expected.join('\n')); + }); }); describe('on Windows', function () {