Skip to content

Commit 5d9bf6d

Browse files
committed
Support for query strings in test_paths
Strips off iany query or anchor params for properly matching incoming URL path with declared test paths Fixes #138
1 parent ca4c34a commit 5d9bf6d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/server.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ var mimeTypes = {
2323

2424
exports.Server = function Server(bsClient, workers) {
2525

26+
var testFilePaths = (Array.isArray(config.test_path) ? config.test_path : [ config.test_path ])
27+
.map(function (path) {
28+
return path.split(/[?#]/)[0];
29+
});
30+
2631
function handleFile(filename, request, response, doNotUseProxy) {
2732
var url_parts = url.parse(request.url, true);
2833
var query = url_parts.query;
@@ -46,13 +51,7 @@ exports.Server = function Server(bsClient, workers) {
4651
};
4752

4853
var filePath = path.relative(process.cwd(), filename);
49-
var pathMatches;
50-
51-
if (typeof config.test_path === 'object') {
52-
pathMatches = (config.test_path.indexOf(filePath) !== -1);
53-
} else {
54-
pathMatches = (filePath === config.test_path);
55-
}
54+
var pathMatches = (testFilePaths.indexOf(filePath) !== -1);
5655

5756
if (pathMatches && mimeType === 'text/html') {
5857
var framework = config['test_framework'];

0 commit comments

Comments
 (0)