Commit bc13687c authored by Clement Ho's avatar Clement Ho

Merge branch 'fix-anchor-scrolling' into 'master'

Fix broken anchor links when special characters are used

Closes #26778

See merge request !8961
parents 840072ec bcf81d82
...@@ -69,6 +69,9 @@ ...@@ -69,6 +69,9 @@
var hash = w.gl.utils.getLocationHash(); var hash = w.gl.utils.getLocationHash();
if (!hash) return; if (!hash) return;
// This is required to handle non-unicode characters in hash
hash = decodeURIComponent(hash);
var navbar = document.querySelector('.navbar-gitlab'); var navbar = document.querySelector('.navbar-gitlab');
var subnav = document.querySelector('.layout-nav'); var subnav = document.querySelector('.layout-nav');
var fixedTabs = document.querySelector('.js-tabs-affix'); var fixedTabs = document.querySelector('.js-tabs-affix');
......
---
title: Fix broken anchor links when special characters are used
merge_request: 8961
author: Andrey Krivko
...@@ -41,6 +41,19 @@ require('~/lib/utils/common_utils'); ...@@ -41,6 +41,19 @@ require('~/lib/utils/common_utils');
}); });
}); });
describe('gl.utils.handleLocationHash', () => {
beforeEach(() => {
window.history.pushState({}, null, '#definição');
});
it('decodes hash parameter', () => {
spyOn(window.document, 'getElementById').and.callThrough();
gl.utils.handleLocationHash();
expect(window.document.getElementById).toHaveBeenCalledWith('definição');
expect(window.document.getElementById).toHaveBeenCalledWith('user-content-definição');
});
});
describe('gl.utils.getParameterByName', () => { describe('gl.utils.getParameterByName', () => {
beforeEach(() => { beforeEach(() => {
window.history.pushState({}, null, '?scope=all&p=2'); window.history.pushState({}, null, '?scope=all&p=2');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment