Skip to content

Commit

Permalink
fix(reporter): remove SHAs from stack traces
Browse files Browse the repository at this point in the history
Again, introduced by 6e31cb2.
  • Loading branch information
vojtajina committed Dec 3, 2013
1 parent bf27e80 commit d7c31f9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/middleware/source_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var createSourceFilesMiddleware = function(filesPromise, serveFile,
/* config.basePath */ basePath) {

return function(request, response, next) {
// TODO(vojta): serve files under urlRoot (also update the formatError)
var requestedFilePath = querystring.unescape(request.url)
.replace(/\?.*$/, '')
.replace(/^\/absolute/, '')
Expand Down
4 changes: 2 additions & 2 deletions lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ var MultiReporter = require('./reporters/multi');
var baseReporterDecoratorFactory = require('./reporters/base').decoratorFactory;

var createErrorFormatter = function(basePath, urlRoot) {
var URL_REGEXP = new RegExp('http:\\/\\/[^\\/]*' + urlRoot.replace(/\//g, '\\/') +
'(base|absolute)([^\\?\\s]*)(\\?[0-9]*)?', 'g');
var URL_REGEXP = new RegExp('http:\\/\\/[^\\/]*' +
'\\/(base|absolute)([^\\?\\s\\:]*)(\\?\\w*)?', 'g');

return function(msg, indentation) {
// remove domain and timestamp from source files
Expand Down
16 changes: 11 additions & 5 deletions test/unit/reporter.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ describe 'reporter', ->
to.be.equal 'file /usr/a.js and /home/b.js\n'


it 'should handle non default karma service folders', ->
# TODO(vojta): enable once we serve source under urlRoot
it.skip 'should handle non default karma service folders', ->
formatError = m.createErrorFormatter '', '/_karma_/'
expect(formatError 'file http://localhost:8080/_karma_/base/usr/a.js and ' +
'http://127.0.0.1:8080/_karma_/base/home/b.js').
to.be.equal 'file /usr/a.js and /home/b.js\n'


it 'should remove timestamps', ->
expect(formatError 'file http://localhost:8080/base/usr/file.js?1325400290544 and ' +
'http://127.0.0.1:8080/absolute/home/file.js?1332400290889').
it 'should remove shas', ->
expect(formatError 'file http://localhost:8080/base/usr/file.js?6e31cb249ee5b32d91f37ea516ca0f84bddc5aa9 and ' +
'http://127.0.0.1:8080/absolute/home/file.js?6e31cb249ee5b32d91f37ea516ca0f84bddc5aa9').
to.be.equal 'file /usr/file.js and /home/file.js\n'


Expand All @@ -54,5 +55,10 @@ describe 'reporter', ->


it 'should restore absolute paths', ->
formatedError = formatError 'at http://local:1233/absolute/usr/path.js?3333'
formatedError = formatError 'at http://local:1233/absolute/usr/path.js?6e31cb249ee5b32d91f37ea516ca0f84bddc5aa9'
expect(formatedError).to.equal 'at /usr/path.js\n'


it 'should preserve line numbers', ->
formatedError = formatError 'at http://local:1233/absolute/usr/path.js?6e31cb249ee5b32d91f37ea516ca0f84bddc5aa9:23'
expect(formatedError).to.equal 'at /usr/path.js:23\n'

0 comments on commit d7c31f9

Please sign in to comment.