I use the following javascript with regex to test url string.
var url = window.location.pathname;
// create regexp to match current url pathname and remove trailing slash if 
// present as it could collide with the link in navigation in case 
// trailing slash wasn't present there
urlRegExp = new RegExp(url == '/' ? window.location.origin + '/?$' : url.replace(/\/$/, '')); 
// now grab every link from the navigation
$('.page-sidebar a').each(function () {
    // and test its normalized href against the url pathname regexp
     if (urlRegExp.test(this.href.replace(/\/$/, ''))) {
         $(this).closest("li").addClass("active");
     }
});
But this regex doesnt include the querystring. How can I do that?
 
     
    