_layouts: fix redirect layout for external URLs

This allows `redirect_to` redirects to external websites;

    curl localhost:4000/samples/library/adminer/
    <!DOCTYPE html>
    <html lang="en-US">
      <meta charset="utf-8">
      <title>Redirecting&hellip;</title>
      <link rel="canonical" href="https://hub.docker.com/_/adminer/"><meta http-equiv="refresh" content="0; url=https://hub.docker.com/_/adminer/">
      <meta name="robots" content="noindex">
      <h1>Redirecting&hellip;</h1>
      <a href="https://hub.docker.com/_/adminer/">Click here if you are not redirected.</a>
      <script>location="https://hub.docker.com/_/adminer/"</script>
    </html>

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2020-10-21 14:17:37 +02:00
parent 03d60f916a
commit 3c869fb0e3

View File

@@ -2,10 +2,15 @@
<html lang="en-US">
<meta charset="utf-8">
<title>Redirecting&hellip;</title>
<link rel="canonical" href="https://docs.docker.com{{ page.redirect.to }}">
<meta http-equiv="refresh" content="0; url={{ page.redirect.to }}">
{%- assign redirect_to = page.redirect.to | remove_first: 'https://docs.docker.com' | remove_first: 'http://docs.docker.com' %}
{%- if redirect_to contains "://" %}
<link rel="canonical" href="{{ redirect_to }}">
{%- else %}
<link rel="canonical" href="https://docs.docker.com{{ redirect_to }}">
{%- endif %}
<meta http-equiv="refresh" content="0; url={{ redirect_to }}">
<meta name="robots" content="noindex">
<h1>Redirecting&hellip;</h1>
<a href="{{ page.redirect.to }}">Click here if you are not redirected.</a>
<script>location="{{ page.redirect.to }}"</script>
<a href="{{ redirect_to }}">Click here if you are not redirected.</a>
<script>location="{{ redirect_to }}"</script>
</html>