From: Bill Erickson Date: Mon, 12 May 2014 17:04:45 +0000 (-0400) Subject: move away from some instances of location.path/search for building URLs X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ca0bb35953df2f21ae995698e5122c6348e0181b;p=working%2FEvergreen.git move away from some instances of location.path/search for building URLs Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/web/js/ui/default/staff/services/navbar.js b/Open-ILS/web/js/ui/default/staff/services/navbar.js index eb0d25eadf..ed017af55a 100644 --- a/Open-ILS/web/js/ui/default/staff/services/navbar.js +++ b/Open-ILS/web/js/ui/default/staff/services/navbar.js @@ -30,11 +30,13 @@ angular.module('egCoreMod') function navTo(path) { // $location.path() does not want a leading ".", - // which 's will have + // which 's will have. + // Note: avoid using $location.path() to derive the new + // URL, since it creates an intermediate path change. path = path.replace(/^\./,''); - - // navigates to the requested path as a new page - $window.location.href = $location.path(path).absUrl(); + var reg = new RegExp($location.path()); + $window.location.href = + $window.location.href.replace(reg, path); } // adds a keyboard shortcut @@ -45,8 +47,15 @@ angular.module('egCoreMod') $scope.applyLocale = function(locale) { // EGWeb.pm can change the locale for us w/ the right param + // Note: avoid using $location.search() to derive a new + // URL, since it creates an intermediate path change. + // Instead, use the ham-fisted approach of killing any + // search args and applying the args we want. $window.location.href = - $location.search('set_eg_locale', locale).absUrl(); + $window.location.href.replace( + /(\?|\&).*/, + '?set_eg_locale=' + encodeURIComponent(locale) + ); } // tied to logout link