Skip to content

Commit 350449d

Browse files
Fix the auto-builder redirect pages to maintain the URL fragment (#7801)
1 parent 85afb17 commit 350449d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

bin/templates/redirect.html.j2

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
<!DOCTYPE html>
22
<meta charset="UTF-8" />
3-
<meta http-equiv="refresh" content="0; URL=../{{ spec_folder }}/" />
3+
<!--
4+
We want the redirect to keep the current URL's fragment, but that can't be
5+
done if without JS support. So we use a meta refresh inside a noscript for
6+
browsers that don't support JS, and do a JS-based redirection otherwise.
7+
-->
8+
<noscript>
9+
<meta http-equiv="refresh" content="0; URL=../{{ spec_folder }}/" />
10+
</noscript>
411
<title>Redirecting...</title>
512
<style>
613
:root {
714
color-scheme: light dark;
815
}
916
</style>
10-
<p>Redirecting to <a href="../{{ spec_folder }}/">{{ spec_folder }}</a>...</p>
17+
<p>Redirecting to <a href="../{{ spec_folder }}/">{{ spec_folder }}</a>...</p>
18+
19+
<script>
20+
// JS-based redirection.
21+
const url = new URL("../{{ spec_folder }}/", location.href);
22+
url.hash = location.hash;
23+
location.replace(url.href);
24+
</script>

0 commit comments

Comments
 (0)