Skip to content

Commit 67dd214

Browse files
authored
fix: transform link[rel] shortcut icon and apple-touch-icon to be absolute (#13077)
closes #10317 This PR builds upon https://github.com/sveltejs/kit/pull/5583/files to include the shortcut icon and apple-touch-icon rel attributes in addition just icon when transforming the asset URL to be absolute.
1 parent 10d0942 commit 67dd214

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/slow-toes-clap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: transform link[rel='shortcut icon'] and link[rel='apple-touch-icon'] to be absolute to avoid console error when navigating

packages/kit/src/runtime/client/client.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ import { INVALIDATED_PARAM, TRAILING_SLASH_PARAM, validate_depends } from '../sh
4646
import { get_message, get_status } from '../../utils/error.js';
4747
import { writable } from 'svelte/store';
4848

49+
const ICON_REL_ATTRIBUTES = new Set(['icon', 'shortcut icon', 'apple-touch-icon']);
50+
4951
let errored = false;
5052

5153
// We track the scroll position associated with each history entry in sessionStorage,
@@ -2307,7 +2309,9 @@ function _start_router() {
23072309
// URLs after a pushState/replaceState, resulting in a 404 — see
23082310
// https://github.com/sveltejs/kit/issues/3748#issuecomment-1125980897
23092311
for (const link of document.querySelectorAll('link')) {
2310-
if (link.rel === 'icon') link.href = link.href; // eslint-disable-line
2312+
if (ICON_REL_ATTRIBUTES.has(link.rel)) {
2313+
link.href = link.href; // eslint-disable-line
2314+
}
23112315
}
23122316

23132317
addEventListener('pageshow', (event) => {

0 commit comments

Comments
 (0)