<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Redirecting...</title>
    <meta http-equiv="refresh" content="0; URL={{url}}">
    <link rel="canonical" href="{{url}}">
  </head>
  <body>
      <p>Redirecting to... <a href="{{url}}">{{url}}</a>.</p>

<script>
    // This handles redirects that involve fragments.
    document.addEventListener('DOMContentLoaded', function() {
        const fragmentMap =
            {{{fragment_map}}}
        ;
        const fragment = window.location.hash;
        if (fragment) {
            let redirectUrl = "{{url}}";
            const target = fragmentMap[fragment];
            if (target) {
                let url = new URL(target, window.location.href);
                redirectUrl = url.href;
            } else {
                let url = new URL(redirectUrl, window.location.href);
                url.hash = window.location.hash;
                redirectUrl = url.href;
            }
            window.location.replace(redirectUrl);
        }
        // else redirect handled by http-equiv
    });
</script>
  </body>
</html>
