X-Git-Url: https://git.exim.org/exim-website.git/blobdiff_plain/b0968890317ffaab0352f6278340d310aacfdc54..9cc5f8ad1e8812053acdfbe9eaa6efa8a045ba31:/templates/static/doc/chapter.js?ds=inline diff --git a/templates/static/doc/chapter.js b/templates/static/doc/chapter.js index add4bd3..45bb4af 100644 --- a/templates/static/doc/chapter.js +++ b/templates/static/doc/chapter.js @@ -1,3 +1,19 @@ +// Rewrite chapter urls using the canonical name. e.g ch01.html becomes introduction.html +(function ($) { + if (document.location.pathname.match(/\/ch\d+\.html$/)) { + var url = document.location.href; + var canonical = $('link[rel="canonical"]').attr('href'); + if (canonical) { + canonical = canonical.replace(/^[^#]+(\/[^\/#]+).*/,'$1'); + url = url.replace(/\/ch\d+\.html/, canonical); + if ("history" in window && "replaceState" in window.history) + window.history.replaceState("", document.title, url); + else + document.location.href = url; + } + } +})(jQuery); + // Warnings about reading old version of documentation (function ($) { if( $.grep( document.cookie.split(/\s*;\s*/), function(a){return a === 'old_version_warning_removed=true' ? true : false }).length === 0 ){