]> git.lizzy.rs Git - rust.git/blob - redirect.js
8c907f5795d324be867a792e25aeac775ebd3b88
[rust.git] / redirect.js
1 (function() {
2     if (window.location.hash) {
3         let code = window.location.hash.replace(/^#/, '');
4         // We have to make sure this pattern matches to avoid inadvertently creating an
5         // open redirect.
6         if (!/^E[0-9]+$/.test(code)) {
7             return;
8         }
9         if (window.location.pathname.indexOf("/error_codes/") !== -1) {
10             // We're not at the top level, so we don't prepend with "./error_codes/".
11             window.location = './' + code + '.html';
12         } else {
13             window.location = './error_codes/' + code + '.html';
14         }
15     }
16 })()