Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(runner): Karma hangs when file paths have \u in them #924
Escape backslashes in paths, which happen in Windows,
to prevent bad IDs (e.g. aaa\uuuu).
Add unit test with path with backslashes.

Closes #924
  • Loading branch information
MrP committed Feb 24, 2014
1 parent 8a30cf5 commit 1199fc4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/middleware/karma.js
Expand Up @@ -101,7 +101,8 @@ var createKarmaMiddleware = function(filesPromise, serveStaticFile,

// TODO(vojta): don't compute if it's not in the template
var mappings = files.served.map(function(file) {
var filePath = filePathToUrlPath(file.path, basePath);
//Windows paths contain backslashes and generate bad IDs if not escaped
var filePath = filePathToUrlPath(file.path, basePath).replace(/\\/g,'\\\\');

return util.format(' \'%s\': \'%s\'', filePath, file.sha);
});
Expand Down
4 changes: 3 additions & 1 deletion test/unit/middleware/karma.spec.coffee
Expand Up @@ -204,12 +204,14 @@ describe 'middleware.karma', ->
servedFiles [
new MockFile('/some/abc/a.js', 'sha_a')
new MockFile('/base/path/b.js', 'sha_b')
new MockFile('\\windows\\path\\uuu\\c.js', 'sha_c')
]

response.once 'end', ->
expect(response).to.beServedAs 200, 'window.__karma__.files = {\n' +
" '/absolute/some/abc/a.js': 'sha_a',\n" +
" '/base/b.js': 'sha_b'\n" +
" '/base/b.js': 'sha_b',\n" +
" '/absolute\\\\windows\\\\path\\\\uuu\\\\c.js': 'sha_c'\n" +
"};\n"
done()

Expand Down

0 comments on commit 1199fc4

Please sign in to comment.