Skip to content

fix: parse Link rel="alternate" in any parameter position#77

Merged
toddr merged 1 commit intomainfrom
koan.toddr.bot/fix-link-alternates-param-order
Apr 23, 2026
Merged

fix: parse Link rel="alternate" in any parameter position#77
toddr merged 1 commit intomainfrom
koan.toddr.bot/fix-link-alternates-param-order

Conversation

@toddr-bot
Copy link
Copy Markdown
Contributor

What: Fix _parse_link_alternates to match rel="alternate" regardless of its position among Link header parameters.

Why: The regex required rel="alternate" immediately after the first ;, so a header like <url>; title="cross-signed"; rel="alternate" silently failed to match. RFC 8288 section 3 allows parameters in any order. While current Let's Encrypt responses put rel first, other CAs may not — and the spec doesn't require it.

How: Split into two regex steps: first check ;\s*rel="alternate" anywhere in the value (case-insensitive per RFC 8288 §2.1.1), then extract the URI from <...>. This is a superset of #72 (which only adds case-insensitivity).

Testing: 13 test cases covering: no header, single/multiple alternates, non-alternate filtering, case variations, whitespace, and — the new cases — rel appearing after other params like title or type.

🤖 Generated with Claude Code

The _parse_link_alternates regex required rel="alternate" to appear
immediately after the first semicolon following the URI-Reference.
This meant Link headers with other parameters before rel (e.g.,
title, type) would silently fail to match, violating RFC 8288
section 3 which allows parameters in any order.

Split the match into two steps: check for rel="alternate" anywhere
in the link value, then extract the URI. Also makes the match
case-insensitive per RFC 8288 section 2.1.1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@toddr-bot
Copy link
Copy Markdown
Contributor Author

Rebase with conflict resolution

Branch koan.toddr.bot/fix-link-alternates-param-order was rebased onto main with automatic conflict resolution.

Stats

2 files changed, 64 insertions(+), 9 deletions(-)
Actions performed
  • Already-solved check: negative (confidence=high, reasoning=PR fix: case-insensitive Link rel="alternate" per RFC 8288 #72 (commit 6ae8766) only added case-insensitivity; the current regex on main still requires rel=)
  • Resolved merge conflicts (1 round(s))
  • Rebased koan.toddr.bot/fix-link-alternates-param-order onto origin/main
  • Pre-push CI check: previous run passed
  • Force-pushed koan.toddr.bot/fix-link-alternates-param-order to origin
  • CI check enqueued in ## CI (async)

CI status

CI will be checked asynchronously.


Automated by Kōan

@toddr-bot toddr-bot force-pushed the koan.toddr.bot/fix-link-alternates-param-order branch from 8e708d2 to 025456b Compare April 23, 2026 14:16
@toddr toddr marked this pull request as ready for review April 23, 2026 14:20
@toddr toddr merged commit 2e82ecf into main Apr 23, 2026
18 checks passed
@toddr toddr deleted the koan.toddr.bot/fix-link-alternates-param-order branch April 23, 2026 14:20
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