mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[7.x] Revert "Handle encoding and decoding of angular route ur… (#54780)
This reverts commit ed97dc6952
.
Co-authored-by: Eli Perelman <eli@eliperelman.com>
This commit is contained in:
parent
2c66ffb3b8
commit
3d67867774
1 changed files with 19 additions and 1 deletions
|
@ -17,11 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import url from 'url';
|
||||
import { unhashUrl } from '../../../../../plugins/kibana_utils/public';
|
||||
import { toastNotifications } from '../../notify/toasts';
|
||||
|
||||
export function registerSubUrlHooks(angularModule, internals) {
|
||||
angularModule.run(($rootScope, Private) => {
|
||||
angularModule.run(($rootScope, Private, $location) => {
|
||||
const subUrlRouteFilter = Private(SubUrlRouteFilterProvider);
|
||||
|
||||
function updateSubUrls() {
|
||||
|
@ -42,6 +43,23 @@ export function registerSubUrlHooks(angularModule, internals) {
|
|||
}
|
||||
}
|
||||
|
||||
$rootScope.$on('$locationChangeStart', (e, newUrl) => {
|
||||
// This handler fixes issue #31238 where browser back navigation
|
||||
// fails due to angular 1.6 parsing url encoded params wrong.
|
||||
const parsedAbsUrl = url.parse($location.absUrl());
|
||||
const absUrlHash = parsedAbsUrl.hash ? parsedAbsUrl.hash.slice(1) : '';
|
||||
const decodedAbsUrlHash = decodeURIComponent(absUrlHash);
|
||||
|
||||
const parsedNewUrl = url.parse(newUrl);
|
||||
const newHash = parsedNewUrl.hash ? parsedNewUrl.hash.slice(1) : '';
|
||||
const decodedHash = decodeURIComponent(newHash);
|
||||
|
||||
if (absUrlHash !== newHash && decodedHash === decodedAbsUrlHash) {
|
||||
// replace the urlencoded hash with the version that angular sees.
|
||||
$location.url(absUrlHash).replace();
|
||||
}
|
||||
});
|
||||
|
||||
$rootScope.$on('$routeChangeSuccess', onRouteChange);
|
||||
$rootScope.$on('$routeUpdate', onRouteChange);
|
||||
updateSubUrls();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue