Skip to content

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

Draft
toddr-bot wants to merge 1 commit intomainfrom
koan.toddr.bot/fix-link-alternates-param-order
Draft

fix: parse Link rel="alternate" in any parameter position#77
toddr-bot wants to merge 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>
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.

1 participant