Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Construct absolute base href using request data. #600

Conversation

superafroman
Copy link

Some browsers (Internet Explorer - sorry :( ) have issues when the base href isn't an absolute URI. It's also defined as being absolute by W3C - https://www.w3.org/TR/html4/struct/links.html#edef-BASE

This PR is a suggestion for how it could be updated - keen to discuss.

@superafroman
Copy link
Author

superafroman commented Mar 11, 2019

A little more info on this, Mozilla specify it can be relative (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) so debatable if it's worth resolving here. You will also introduce an issue if the site is being served from different domains, where the first request will set the domain of the base URI for all requests. (template processing being done only on first load in production)

In addition, having an absolute base URI doesn't fix all issues in IE. Sapper uses document.baseURI for goto and prefetch which doesn't get populated in IE <= 11.

So a polyfill is still needed. I'll leave this PR here for anyone else to feed in to if they like.

@thgh thgh mentioned this pull request Nov 9, 2019
@arve0
Copy link

arve0 commented Apr 10, 2020

Sapper uses document.baseURI for goto and prefetch which doesn't get populated in IE <= 11.

Adding: <base> also affects URLs for <a> anchor links and <img> images in browsers not supporting "semi-absolute" href, not only the javascript APIs. Using absolute href overcomes this, which makes it possible to create apps that works on older browsers (assuming no dependency to running JS in the client).

Stumbled upon this when doing a funny side project, taking progressive enhancement to the extreme; create an app that works in both IE5.01 and modern browsers.

I'll admit the silliness of using browsers released in 1999 and do not expect sapper to support it, though it works! I find that intriguing, considering the 20-year age gap 😁

@benmccann
Copy link
Member

Sorry this had gone unreviewed for so long. It looks like there's a merge conflict here. Maybe it's better to try to make sure SvelteKit works as desired than trying to get it in here at this point?

@benmccann
Copy link
Member

SvelteKit 1.0 is now out and Sapper is deprecated, so I'm going to close this

@benmccann benmccann closed this Jan 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants