Skip to content

Fix local storyboard requests on Crystal >= 1.16.0 #5315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

syeopite
Copy link
Member

Crystal 1.16.0 fixed the parsing of some weird-looking paths meaning that //api/v1/storyboards/sb/i/... will no longer get parsed into a request target of /v1/storyboards/sb/i/... within requests.

But the fix is a bit more annoying than just changing a path. The "new" existence of the double slash means that StaticFileHandler will process and redirect the request to a normalized path with only a single slash. This redirect however does not preserve url query parameters which are needed to request storyboards from YouTube.

Then there's the fact that the status code error handlers are disabled for the API routes, meaning that there is no handler to actually process the request with.

This PR patches Kemal's StaticFileHandler to preserve query parameters when redirecting, and adds the /api/v1/storyboard/sb/* -> /sb/i/*/ redirect directly into Kemal's ExceptionHandler for now.

In the future a dedicated handler should be created to properly handle http status code conditions on the API routes.

Crystal 1.16.0 fixed the parsing of some weird-looking paths meaning
that `//api/v1/storyboards/sb/i/...` will no longer get parsed into a
request target of `/v1/storyboards/sb/i/...` within requests.

But the fix is a bit more convoluted than just changing a path. The new
presence of double slash means that `StaticFileHandler` will process and
redirect the request to a normalized path with only a single slash.
This redirect however does not preserve url query parameters which are
needed to request storyboards from YouTube.

Then there's the fact that the status code error handlers are disabled
for the API routes, meaning that there is no handler to actually process
the request with.

This PR patches Kemal's `StaticFileHandler` to preserve query parameters
when redirecting, and adds the `/api/v1/storyboard/sb/*` ->
`/sb/i/*/` redirect directly into Kemal's `ExceptionHandler` for now.

In the future a dedicated handler should be created to properly handle
http status code conditions on the API routes.
@syeopite syeopite requested a review from a team as a code owner May 18, 2025 06:30
@syeopite syeopite requested review from alexmaras and removed request for a team May 18, 2025 06:30
@syeopite syeopite added the module:player Impacts the video player of Invidious label May 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:player Impacts the video player of Invidious
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant