β¨ feat(redirect): add update command and normalise FQDN handling - #1
Merged
Merged
Conversation
Add redirect update capability that allows modifying redirects in place without recreating them (preserving certificates). Introduce toRedirectHost() normalisation to handle bare labels, apex notation, and idempotent FQDN qualification throughout the redirect command surface. Update README with examples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
π Description
New:
gandi redirect update <domain> <source> [target]Updates a web redirect in place via
PATCH /v5/domain/domains/{domain}/webredirs/{host}, instead of the old delete-then-add dance. Flags:-t/--type,-p/--protocol,--override/--no-override. Only the fields you actually supply are sent, so anything you don't touch is preserved β running it with no target and no flags errors with "Nothing to update" rather than firing an empty PATCH.This matters because delete-then-add was the only way to change a redirect's target before, and that discards the Gandi-issued TLS certificate and resets
protocol. Verified live: updatingtrakt.kud.iopreservedprotocol: httpsuntouched.Known limit, not a bug: Gandi's PATCH has no
hostfield, soupdatecan't move a redirect to a different subdomain β that still needs delete + add.Fix: host handling was wrong in three places
Gandi identifies a redirect by its fully-qualified source host β in the list response, in the
{host}path segment, and in the POST body. The CLI assumed a bare label instead:redirect listprinted a doubled suffix (500px.kud.io.kud.io) β now prints500px.kud.io.redirect deletebuilt its path as/webredirs/{label}, which the API rejects with 400 β now sends the FQDN.redirect add's success line had the same doubling.New exported helper
toRedirectHost(domain, host)normalises either spelling to the FQDN and is idempotent, so scripts already passing a bare label keep working.β Behaviour change:
redirect listoutput andredirect delete's request path both change as a result of the fix above. Both are bug fixes, but anyone scripting against the old output would notice.Tests
New
describeblocks insrc/lib/api.test.ts:toRedirectHostβ bare label, already-qualified, multi-level, apex/@/empty, idempotency, and thewww.notex.comnear-miss case.addRedirect/updateRedirect/deleteRedirectβ request shape, and theoverride:falsevs omitted distinction.Docs
README documents the new command and that sources may be given as bare or fully qualified.
π½οΈ Screencast
No visual changes.
β How to Validate
npm install && npm run buildgandi redirect list <domain>β confirm hosts print without a doubled domain suffix.gandi redirect update <domain> <source> --protocol https(no target) β confirm onlyprotocolchanges and the existing target/type/override are untouched.gandi redirect update <domain> <source>with no flags and no target β confirm it errors with "Nothing to update" instead of sending a PATCH.gandi redirect delete <domain> <source>β confirm the request succeeds (previously 400'd on a bare label).npm testβ see the newtoRedirectHostand redirect-request-shape coverage insrc/lib/api.test.ts.π οΈ Developer Checklist
npm testβ 41 passing)Validated locally:
npm run lintclean,npm test(41 passing),npm run build(tsc) clean, and a liveupdateagainsttrakt.kud.ioconfirmed via a direct API read. No further manual/exploratory testing beyond that was performed.