Fixed crash after navigation caused 404 when using instant loading

This commit is contained in:
squidfunk 2023-11-02 11:50:45 +01:00
parent dfa5f03138
commit 494cae1e36
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
4 changed files with 12 additions and 12 deletions

View File

@ -249,7 +249,7 @@
</script> </script>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/bundle.aecac24b.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.a1c919d2.min.js' | url }}"></script>
{% for script in config.extra_javascript %} {% for script in config.extra_javascript %}
{{ script | script_tag }} {{ script | script_tag }}
{% endfor %} {% endfor %}

View File

@ -47,7 +47,6 @@ import {
import { configuration, feature } from "~/_" import { configuration, feature } from "~/_"
import { import {
Viewport, Viewport,
getElement,
getElements, getElements,
getLocation, getLocation,
getOptionalElement, getOptionalElement,
@ -89,7 +88,8 @@ function lookup(head: HTMLHeadElement): Map<string, HTMLElement> {
// resolution. The next time we refactor instant loading, we should use the // resolution. The next time we refactor instant loading, we should use the
// location subject as a source, which is also used for anchor links tracking, // location subject as a source, which is also used for anchor links tracking,
// but for now we just rely on canonical. // but for now we just rely on canonical.
const canonical = getElement<HTMLLinkElement>("[rel=canonical]", head) const canonical = getOptionalElement<HTMLLinkElement>("[rel=canonical]", head)
if (typeof canonical !== "undefined")
canonical.href = canonical.href.replace("//localhost:", "//127.0.0.1") canonical.href = canonical.href.replace("//localhost:", "//127.0.0.1")
// Create tag map and index elements in head // Create tag map and index elements in head
@ -107,7 +107,7 @@ function lookup(head: HTMLHeadElement): Map<string, HTMLElement> {
continue continue
// Resolve URL relative to current location // Resolve URL relative to current location
const url = new URL(value, canonical.href) const url = new URL(value, canonical?.href)
const ref = el.cloneNode() as HTMLElement const ref = el.cloneNode() as HTMLElement
// Set resolved URL and retrieve HTML for deduplication // Set resolved URL and retrieve HTML for deduplication