Skip to content

arnau/linkheader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Link Header parser

linkheader is a parser for the RFC8288.

Goals

  • Forgiving parser.
    • A link with no "rel" param is not an error.
    • A link with many "rel" params is not an error.
    • UTF-8 characters outside the US-ASCII range are not an error.
    • A link with many "anchor" params is not an error.
  • Quoted and unquoted param values are equivalent. E.g. hreflang=en is the same as hreflang="en".
  • Collect the link relation type when available.
  • Explode to individual links when given a multi-token "rel".
  • Change the link context when a valid "anchor" is present.
  • Star params (e.g. title*=UTF-8'en'foo%20bar) expect a valid RFC8187 value.
  • Compose relative targets with the given context.
  • Collect the "title" param prioritising title* when present.
  • Collect the "hreflang" param.
  • Collect the "type" param.
  • Collect the "media" param.

Non-goals

  • "rev" is not treated specially. It is just another param.
  • "rel" values are not validated against the IANA registry.
  • Language tags RFC5646 are not parsed.
  • RFC8187 values not in UTF-8 are not decoded.
  • Media types RFC2046 are not parsed.
  • The special (HTML) "rel" alternate stylesheet is not handled. Any multi-token "rel" expands to individual links with a different relation type.

Licence

linkheader is licensed under the MIT License.

Releases

No releases published

Packages

No packages published

Languages