Hrana URL strings: don't append pipeline/cursor routes blindly #919
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.
Atm. Hrana connection takes in a base_url and internally constructs a pipeline (/v3/pipeline) and cursor (/v3/cursor) URLs out of it. The thing is that it did so without properly checking if it's ok to do so. Therefore if someone set a base URL to ie.
libsql://pen.turso.io/?authToken=
it wouldn't immediately fail, but instead the requests would be send to an invalid endpoint (/?authToken=/v3/cursor
instead of/v3/cursor/?authToken=
). This PR changes that behaviour.Now, we could think: why not use native URL parsing capabilities and use Url all the way down:
http
based one which comes with dependencies that we don't want on Cloudflare end.url
crate, which it uses internally) comes with some limitations ie.url.set_scheme
(which we need for things like switchinglibsql
→https
) explicitly disallows switching schemes of specific kinds, our use case included. Moreover it doesn't provide API to override that behaviour. Btw.url
crate is the most popular Rust crate used for this purpose.