forked from amazingfate/help
Current links from outside (like the wiki) will cause excess history entries when clicking the https://help.libreoffice.org/ link, breaking the back button. See the example of the visited pages below. Ideally only the referring page and the final page should be in the history, allowing the user to navigate back. 1. https://help.libreoffice.org/Main_Page 2. https://help.libreoffice.org/ - 302 redirect 3. https://help.libreoffice.org/help.html - window.location.href 4. https://help.libreoffice.org/latest/index.html - window.location.href 5. https://help.libreoffice.org/latest/en-US/text/shared/05/new_help.html?&DbPAR=WRITER&System=UNIX The second 302 redirect is fine as it simply replaces the history. The two window.location.href assigments however should be replaced with window.location.replace. Change-Id: I6fbe7141de87c939aa816fdfc2fe5255e9792e0b Reviewed-on: https://gerrit.libreoffice.org/c/help/+/106429 Tested-by: Jenkins Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
47 lines
1.4 KiB
HTML
47 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<!--
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
-->
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval' piwik.documentfoundation.org"/>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript">
|
|
function getParameterByName(name, url) {
|
|
if (!url) {
|
|
url = window.location.href;
|
|
}
|
|
name = name.replace(/[\[\]]/g, "\\$&");
|
|
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
|
|
var results = regex.exec(url);
|
|
if (!results) {
|
|
return null;
|
|
}
|
|
if (!results[2]) {
|
|
return '';
|
|
}
|
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
|
}
|
|
|
|
var url = window.location.href;
|
|
var n = url.indexOf('?');
|
|
if (n != -1) {
|
|
// the URL came from LibreOffice help (F1)
|
|
var version = getParameterByName("Version", url);
|
|
var query = url.substr(n + 1, url.length);
|
|
var newURL = version + '/index.html?' + query;
|
|
window.location.replace(newURL);
|
|
} else {
|
|
window.location.replace('latest/index.html');
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|