Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Prevent multiple 'grep=' querystring params in html reporter

Vlad Magdalin12b6ed9d6efc
diff --git a/lib/reporters/html.js b/lib/reporters/html.js
index 31ec1061..aec2af0d 100644
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -183,6 +183,12 @@ function HTML(runner) {
*/
var makeUrl = function makeUrl(s) {
var search = window.location.search;
+
+ // Remove previous grep query parameter if present
+ if (search) {
+ search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
+ }
+
return window.location.pathname + (search ? search + '&' : '?' ) + 'grep=' + encodeURIComponent(s);
};