Commit bcf81d82 authored by Andrey Krivko's avatar Andrey Krivko

Fix broken anchor links when special characters are used

parent 412ab17d
......@@ -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');
......
---
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');
......
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