Convert absolute into relative paths #12
Merged
+15
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Removes all URLs of the form "/css/...", "/index.js", etc., replacing them with "css/...", "index.js".
Without this fix, we can't host the playground in subpaths. For example, hosting it at
https://gleam.run/playground
would have the website try to accesshttps://gleam.run/index.js
,https://gleam.run/css/theme.css
and so on, rather thanhttps://gleam.run/playground/index.js
andhttps://gleam.run/playground/css/theme.css
. That is, links aren't respecting the base.This is particularly annoying while testing locally, as the playground might be in a folder. However, this fix is also required for my use case: I'm hosting my customized playground on GitHub Pages, which uses the repository name. Regardless, I believe having the website respect its base is nice and flexible, not to mention that lots of existing path constants were already used in a relative way (such as
const prelude
inplayground.gleam
).The only assumption I make here is that files in
static
are exported to the same folder whereindex.html
is, as well asprecompiled/
, which is indeed the case.I've tested this PR locally with
python3 -m http.server
on a parent directory (i.e. the playground is available atlocalhost:8000/public
) and all seems to work.