Move version cache buster to path for js#1582
Open
siliconfeces wants to merge 2 commits into
Open
Conversation
psilabs-dev
reviewed
May 30, 2026
| # Routers used for all loginless routes | ||
| my $public_routes = $self->routes; | ||
|
|
||
| $public_routes->get( '/js/:version/*filepath' => [ version => qr/\d+\.\d+\.\d+/ ] )->to( |
Contributor
Contributor
Author
There was a problem hiding this comment.
The mojolicious path class is a bit "special" (never got mergeand contains to do anything useful), but I think I've managed to block that stuff now, albeit a bit heavy-handed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

I wasn't 100% pleased with how importmap-reliant JS imports were, so I changed approach. It also prevented most IDEs from resolving the imports for autocomplete, so that works better now.
Now the version cache-buster is part of the path and doesn't require importmap-entries for "ordinary" non-vendor javascript files. This allows you to do relative imports (like
./server.jsinstead ofmod/server).A disadvantage is that importing stuff from HTML files is a touch uglier again as you need to build the path each time rather than just once in the importmap.