Remove leading slash in generated asset paths - #932
madeline-os wants to merge 2 commits into
Conversation
[#831](#831) changed the way that we generate routes for static assets. The old approach would place the assets at a path starting with "static". The new approach added a leading slash, which, when rendered in URLs, would lead to double slashes at the beginning of routes. This change brings the new behavior in line with the old behavior.
|
This would be undoing a breaking change that was made a long time ago, but that itself is a breaking change. So I am leaving this up for consideration. |
|
Obelisk also includes a When that base tag is present, relative URLs (e.g., Ultimately, we will want the base url to be configurable (likely via the route config). If it's set properly, the relative and absolute URLs should, again, resolve to the same thing. Are there known cases where the change from !831 results in broken asset links? If not, perhaps the addition/removal of the prefix slash is not a noticeable change, even if it is technically a breaking one. It seems like we're redundantly absolute right now, and there's little practical difference from the perspective of users. The exception for iOS and the behavior on Android both bear further investigation and documentation before any change is made. |
Absolutely, that's how we noticed this - some images broke after bumping obelisk. |
|
Reproduced same issue in the skeleton under |
|
How are you generating the |
Oh, well I'm not, I meant locally on ob run (pre #930). |
|
Hmm actually I might have been confused. I can't reproduce the |
|
I've determined that this is an issue for Android development. An asset referenced in an Android app will not be found unless the extra slash is dropped. |
|
Huuuh something's fishy about my last two comments, it seems like I was getting my wires crossed with #930, hence the
On current develop, --- a/skeleton/frontend/src/Frontend.hs
+++ b/skeleton/frontend/src/Frontend.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
@@ -42,7 +43,10 @@ frontend = Frontend
^. js ("skeleton_lib" :: T.Text)
^. js1 ("log" :: T.Text) ("Hello, World!" :: T.Text)
- elAttr "img" ("src" =: $(static "obelisk.jpg")) blank
+ getConfig "common/route" >>= \case
+ Nothing -> blank
+ Just r -> do
+ elAttr "img" ("src" =: (T.decodeUtf8 r <> "/" <> $(static "obelisk.jpg"))) blank
whereas before #831 the same change gives me a working image and |
|
Was this closed because the new behavior is being adopted or? |
|
Yes. I noticed that the mobile infra already had a provision for dropping the slash: https://github.com/reflex-frp/reflex-dom/blob/develop/reflex-dom/java/org/reflexfrp/reflexdom/MainWidget.java#L161 |




#831 changed the
way that we generate routes for static assets. The old approach would
place the assets at a path starting with "static". The new approach
added a leading slash, which, when rendered in URLs, would lead to
double slashes at the beginning of routes in places where the user had
not expected there to be a slash. This can lead to 404's for assets for
older projects.
This change brings the current behavior in line with the old behavior.
I have:
developbranchhlint .(lint found code you did not write can be left alone)$(nix-build -A selftest --no-out-link)nix-build release.nix -A build.x86_64-linux --no-out-link(orx86_64-darwinon macOS)