fix(config): keep the base url path prefix when building request urls

Merged
RA
25d ago
+48-6

Summary

Config::build joins the endpoint path onto the base url with Url::join. Every endpoint path starts with /, so join treats it as absolute and discards any path in the base url. A base url such as https://proxy.example.com/resend, set with ConfigBuilder::base_url or RESEND_BASE_URL, sends GET /emails to https://proxy.example.com/emails.

The ConfigBuilder::base_url docs describe pointing the client at a proxy, which commonly lives under a path prefix.

This change appends a trailing slash to the base path when it is missing and joins the endpoint path without its leading slash. A base url without a path builds the same urls as before.

Testing

  • Two unit tests in src/config.rs build request urls for a base url without a path, and for a base url with a path, with and without a trailing slash.
  • With the source change reverted, the prefix test fails. With the change, both pass, with and without the blocking feature.
  • cargo fmt --check and cargo clippy --all-targets report nothing for the changed file.

Summary by cubic

Fixes Config::build so a path prefix in the base url is kept when building request urls. Previously a base url like https://proxy.example.com/resend sent requests to https://proxy.example.com/emails because Url::join treated the endpoint path as absolute and dropped the base path. Now the base path is preserved: trailing slashes are trimmed from it and the endpoint path is joined without its leading slash. Base urls without a path build the same urls as before, and tests cover both cases.