Fix broken anchor links when special characters are used
This commit is contained in:
parent
412ab17d3f
commit
bcf81d82fa
3 changed files with 20 additions and 0 deletions
|
@ -69,6 +69,9 @@
|
|||
var hash = w.gl.utils.getLocationHash();
|
||||
if (!hash) return;
|
||||
|
||||
// This is required to handle non-unicode characters in hash
|
||||
hash = decodeURIComponent(hash);
|
||||
|
||||
var navbar = document.querySelector('.navbar-gitlab');
|
||||
var subnav = document.querySelector('.layout-nav');
|
||||
var fixedTabs = document.querySelector('.js-tabs-affix');
|
||||
|
|
4
changelogs/unreleased/fix-anchor-scrolling.yml
Normal file
4
changelogs/unreleased/fix-anchor-scrolling.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
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');
|
|||
});
|
||||
});
|
||||
|
||||
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', () => {
|
||||
beforeEach(() => {
|
||||
window.history.pushState({}, null, '?scope=all&p=2');
|
||||
|
|
Loading…
Reference in a new issue