13.69. DD 69: Exchange Base URL Completion#
13.69.1. Summary#
Define the request, which turns user-provided input (like exchange.example.com or just example.com) into a canonical,
validated HTTPS exchange base URL. Validation requires that GET <base>/keys returns a valid
ExchangeKeysResponse object.
13.69.2. Motivation#
Users may provide incomplete or ambiguous input when configuring an exchange. For example, they may type just
example.com instead of the full https://exchange.example.com/.
The system must normalize, complete, and validate such inputs to ensure that only valid exchanges are accepted.
This improves robustness and user experience while preventing misconfiguration.
13.69.3. Requirements#
Accepts a single string from the user (host or URL).
Supports inputs like
exchange.example.com,example.com, orhttps://exchange.example.com/.Always enforces HTTPS.
Base URL must end with a single
/and omit ports.Must validate by requesting
GET <base>/keysand checking for a valid ExchangeKeysResponse object.Must support a local list of trusted exchanges for resolution of ambiguous inputs or typos (70% Levenshtein similarity).
13.69.4. Proposed Solution#
Process:
Clean up locally
Trim spaces and lowercase scheme/host.
Default scheme to
https://if missing.Reject non-HTTPS schemes.
Remove explicit port and strip query/fragment.
Ensure a trailing slash.
Candidate base URLs
If input host starts with
exchange., use directly.If input is a bare domain, construct
https://exchange.<domain>/as a second candidate.
Network check (keys)
For each candidate, perform
GET <base>/keys.Follow HTTPS redirects within limits.
Accept if the final response is a valid ExchangeKeysResponse.
Otherwise, treat as protocol failure.
List of trusted exchanges
Check the input against a local list of trusted exchanges.
Match by exact part match of hostname and fuzzy match (≥70% Levenshtein).
Return
bad-protocoland if trusted entry(ies) is(are) found, return it(them) back in object(sugestions: array).
13.69.4.1. Outcome values#
ok — Keys validated; return canonical base.
bad-syntax — Input invalid (e.g., non-HTTPS scheme).
bad-network — Network failure (DNS/connect/TLS/timeout).
bad-protocol — Response received but not a valid exchange.
13.69.4.2. Canonicalization of output#
Always return in the form
https://<lowercased-host>/.No ports, queries, or fragments.
13.69.4.3. Examples#
exchange.example.com-> ok, returnshttps://exchange.example.com/.example.com-> tryhttps://example.com/keysfirst. If not valid, then tryhttps://exchange.example.com/keys. If that works → ok, returnshttps://exchange.example.com/.https://exchange.example.com/with/keysreturning something other than a valid ExchangeKeysResponse object -> bad-protocol.http://exchange.example.com-> bad-syntax (HTTPS required).example.comwhere/keysredirects tohttps://api.example.com/keysand returns valid data -> ok, returnshttps://api.example.com/.DNS failure -> bad-network.
13.69.5. Definition of Done#
Request implemented and documented.
Unit tests cover: - valid inputs, - redirects, - trusted exchange fallback, - failure cases (syntax, network, protocol).
Feature is enabled by default once tests pass.
13.69.6. Alternatives#
13.69.7. Drawbacks#
Requires maintaining a local list of trusted exchanges and fuzzy matching.
Adds network overhead (
GET /keysprobes).Possible user confusion if multiple trusted exchanges are suggested as fuzzy matches.
13.69.8. Discussion / Q&A#
(To be filled in with results from discussions on mailing lists / personal communication.)