Skip to content

Commit 40fc16d

Browse files
committed
aliases: Keep not only anchor but also query when redirecting
We just fixed a bug where clicking on an operating system button in https://git-scm.com/downloads/guis replaced the URL by an incorrect URL, e.g. https://git-scm.com/download/guis?os=linux instead of https://git-scm.com/downloads/guis?os=linux (note the singular "download" in the incorrect URL). We want to handle such URLs gracefully, though, just in case those links were already shared. Therefore we are about to add aliases, but the way aliases are currently handled loses the `?os=linux` part of the URL, which is rather important. Let's copy that part (which is called `window.location.search` in Javascript) into the new URL in the Javascript part of the redirect page (which is typically taking precedence over the `<meta http-equiv="refresh" ...>` tag). Signed-off-by: Johannes Schindelin <[email protected]>
1 parent b43faa9 commit 40fc16d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

layouts/_default/baseof.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<meta name="robots" content="noindex">
1414
</head>
1515
<body>
16-
<script>window.location.replace(document.querySelector("link[rel='canonical']").href + window.location.hash)</script>
16+
<script>window.location.replace(document.querySelector("link[rel='canonical']").href + window.location.search + window.location.hash)</script>
1717
<h1>Redirecting&hellip;</h1>
1818
<a href="{{ $redirect_to }}">Click here if you are not redirected.</a>
1919
</body>

layouts/alias.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<meta name="robots" content="noindex">
99
</head>
1010
<body>
11-
<script>window.location.replace(document.querySelector("link[rel='canonical']").href + window.location.hash)</script>
11+
<script>window.location.replace(document.querySelector("link[rel='canonical']").href + window.location.search + window.location.hash)</script>
1212
<h1>Redirecting&hellip;</h1>
1313
<a href="{{ $redirect_to }}">Click here if you are not redirected.</a>
1414
</body>

0 commit comments

Comments
 (0)