diff --git a/lib/middleware/source_files.js b/lib/middleware/source_files.js index 759a464c6..7b46fdd9b 100644 --- a/lib/middleware/source_files.js +++ b/lib/middleware/source_files.js @@ -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/, '') diff --git a/lib/reporter.js b/lib/reporter.js index 4b065ec3f..1bf382aa4 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -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 diff --git a/test/unit/reporter.spec.coffee b/test/unit/reporter.spec.coffee index fa416f24e..71e12ce38 100644 --- a/test/unit/reporter.spec.coffee +++ b/test/unit/reporter.spec.coffee @@ -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' @@ -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'