From 91828f981154dfea20453a99460d5c2413f9d7ef Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Fri, 12 Sep 2014 23:51:01 -0700 Subject: [PATCH] HTML reporter: preserve query params when navigating to suites/tests see #830 --- lib/reporters/html.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/reporters/html.js b/lib/reporters/html.js index 8b44e3ed50..8c41f0552f 100644 --- a/lib/reporters/html.js +++ b/lib/reporters/html.js @@ -177,14 +177,23 @@ function HTML(runner) { }); } +/** + * Makes a URL, preserving querystring ("search") parameters. + * @param {string} s + * @returns {string} your new URL + */ +var makeUrl = function makeUrl(s) { + var search = window.location.search; + return (search ? search + '&' : '?' ) + 'grep=' + encodeURIComponent(s); +}; + /** * Provide suite URL * * @param {Object} [suite] */ - HTML.prototype.suiteURL = function(suite){ - return '?grep=' + encodeURIComponent(suite.fullTitle()); + return makeUrl(suite.fullTitle()); }; /** @@ -194,7 +203,7 @@ HTML.prototype.suiteURL = function(suite){ */ HTML.prototype.testURL = function(test){ - return '?grep=' + encodeURIComponent(test.fullTitle()); + return makeUrl(test.fullTitle()); }; /**