[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:
Josh Dover 2020-01-14 16:53:31 -07:00 committed by GitHub
parent 2c66ffb3b8
commit 3d67867774
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();