Skip to content

Commit bf73f50

Browse files
committed
fix innerlink issue
1 parent e97fe73 commit bf73f50

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/components/InnerLinkPreview.astro

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,12 @@
225225
// Construct a full URL from a relative path, ensuring it uses the page's origin.
226226
const url = new URL(rawHref, window.location.origin);
227227
// Force HTTPS protocol to prevent mixed content issues in production.
228-
url.protocol = 'https:';
228+
url.protocol = 'https';
229+
230+
// Ensure trailing slash to prevent server-side redirects to http.
231+
if (!url.pathname.endsWith('/') && !url.pathname.split('/').pop()?.includes('.')) {
232+
url.pathname += '/';
233+
}
229234

230235
return url.href;
231236
}

0 commit comments

Comments
 (0)