Skip to content

fix: auto-sanitize TX_POOL_URL trailing slash#224

Merged
prestwich merged 3 commits intomainfrom
samwise/eng-1531-tx-pool-url-sanitize-v2
Feb 13, 2026
Merged

fix: auto-sanitize TX_POOL_URL trailing slash#224
prestwich merged 3 commits intomainfrom
samwise/eng-1531-tx-pool-url-sanitize-v2

Conversation

@init4samwise
Copy link
Contributor

Summary

Automatically ensures TX_POOL_URL has a trailing slash during config sanitization, fixing url.join() behavior for endpoint construction.

Problem

The Rust url.join() method behaves differently depending on whether the base URL ends with a trailing slash:

  • http://example.com/api/ + join("transactions") = http://example.com/api/transactions
  • http://example.com/api + join("transactions") = http://example.com/transactions

This caused a confusing requirement in the README for users to manually add trailing slashes.

Solution

  • Add sanitize() method to BuilderConfig that ensures trailing slash
  • Apply sanitization on config load in config_from_env()
  • Remove manual trailing slash requirement from README
  • Add 6 unit tests for URL sanitization

Testing

Added unit tests covering:

  • URLs without trailing slash get sanitized
  • URLs with trailing slash remain unchanged
  • URLs with paths (with/without trailing slash)
  • Verify url.join() works correctly after sanitization

Closes ENG-1531

Automatically ensures TX_POOL_URL has a trailing slash during config
sanitization, fixing url.join() behavior for endpoint construction.

- Add sanitize() method to BuilderConfig
- Apply sanitization on config load in config_from_env()
- Remove manual trailing slash requirement from README
- Add 6 unit tests for URL sanitization

Closes ENG-1531
@prestwich
Copy link
Member

@init4samwise CI is broken

The test url_without_trailing_slash_gets_sanitized was incorrectly
asserting that parsing "http://localhost:9000" would give a URL
without a trailing slash. Per URL spec, a URL without an explicit
path gets the root path "/", which DOES end with a slash.

Renamed test to root_url_already_has_trailing_slash and updated
assertions to document this behavior correctly - the sanitization
is actually a no-op for root URLs since they already have the
trailing slash.
@prestwich prestwich merged commit 0848093 into main Feb 13, 2026
5 checks passed
@prestwich prestwich deleted the samwise/eng-1531-tx-pool-url-sanitize-v2 branch February 13, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants