[chrome] remove disableAutoAngularUrlEncodingFix() (#33136) (#33268)

This commit is contained in:
Spencer 2019-03-15 13:52:11 -07:00 committed by GitHub
parent 93d288454f
commit 0e131d6f13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 21 deletions

View file

@ -34,12 +34,6 @@ const URL_LIMIT_WARN_WITHIN = 1000;
export function initAngularApi(chrome, internals) {
chrome.getFirstPathSegment = _.noop;
internals.disableAutoAngularUrlEncodingFix = false;
chrome.disableAutoAngularUrlEncodingFix = () => {
internals.disableAutoAngularUrlEncodingFix = true;
return chrome;
};
chrome.setupAngular = function () {
const kibana = uiModules.get('kibana');

View file

@ -74,20 +74,18 @@ export function kbnChromeProvider(chrome, internals) {
}
}
if (!internals.disableAutoAngularUrlEncodingFix) {
$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 absUrlHash = url.parse($location.absUrl()).hash.slice(1);
const decodedAbsUrlHash = decodeURIComponent(absUrlHash);
const hash = url.parse(newUrl).hash.slice(1);
const decodedHash = decodeURIComponent(hash);
if (absUrlHash !== hash && decodedHash === decodedAbsUrlHash) {
// replace the urlencoded hash with the version that angular sees.
$location.url(absUrlHash).replace();
}
});
}
$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 absUrlHash = url.parse($location.absUrl()).hash.slice(1);
const decodedAbsUrlHash = decodeURIComponent(absUrlHash);
const hash = url.parse(newUrl).hash.slice(1);
const decodedHash = decodeURIComponent(hash);
if (absUrlHash !== hash && decodedHash === decodedAbsUrlHash) {
// replace the urlencoded hash with the version that angular sees.
$location.url(absUrlHash).replace();
}
});
$rootScope.$on('$routeChangeSuccess', onRouteChange);
$rootScope.$on('$routeUpdate', onRouteChange);

View file

@ -45,7 +45,6 @@ declare interface Chrome extends ChromeNavLinks {
addApplicationClass(classNames: string | string[]): this;
removeApplicationClass(classNames: string | string[]): this;
getApplicationClasses(): string;
disableAutoAngularUrlEncodingFix(): this;
}
declare const chrome: Chrome;