提交 bc13687c 编写于 作者: C Clement Ho

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

Fix broken anchor links when special characters are used

Closes #26778

See merge request !8961
...@@ -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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册