Skip to content

hugoalh/http-header-link-es

HTTP Header Link (ES)

⚖️ MIT

🔗 GitHub JSR NPM

An ECMAScript module to handle the HTTP header Link according to the specification RFC 8288.

🎯 Targets

Runtime \ Source GitHub Raw JSR NPM
Bun >= v1.1.0 ✔️ ✔️
Deno >= v2.1.0 ✔️ ✔️ ✔️
NodeJS >= v20.9.0 ✔️ ✔️

🛡️ Runtime Permissions

This does not request any runtime permission.

#️⃣ Sources

  • GitHub Raw
    https://raw.githubusercontent.com/hugoalh/http-header-link-es/{Tag}/mod.ts
    
  • JSR
    jsr:@hugoalh/http-header-link[@{Tag}]
    
  • NPM
    npm:@hugoalh/http-header-link[@{Tag}]
    

Note

  • It is recommended to include tag for immutability.
  • These are not part of the public APIs hence should not be used:
    • Benchmark/Test file (e.g.: example.bench.ts, example.test.ts).
    • Entrypoint name or path include any underscore prefix (e.g.: _example.ts, foo/_example.ts).
    • Identifier/Namespace/Symbol include any underscore prefix (e.g.: _example, Foo._example).

⤵️ Entrypoints

Name Path Description
. ./mod.ts Default.

🧩 APIs

  • class HTTPHeaderLink {
      constructor(...inputs: (string | Headers | HTTPHeaderLink | HTTPHeaderLinkEntry[] | Response)[]);
      add(...inputs: (string | Headers | HTTPHeaderLink | HTTPHeaderLinkEntry[] | Response)[]): this;
      entries(): HTTPHeaderLinkEntry[];
      getByParameter(key: string, value: string): HTTPHeaderLinkEntry[];
      getByRel(value: string): HTTPHeaderLinkEntry[];
      hasParameter(key: string, value: string): boolean;
      toString(): string;
      static parse(...inputs: (string | Headers | HTTPHeaderLink | HTTPHeaderLinkEntry[] | Response)[]): HTTPHeaderLink;
      static stringify(...inputs: (string | Headers | HTTPHeaderLink | HTTPHeaderLinkEntry[] | Response)[]): string;
    }
  • type HTTPHeaderLinkEntry = [
      uri: string,
      parameters: { [key: string]: string; }
    ];

Note

✍️ Examples

  • new HTTPHeaderLink(`<https://example.com>; rel="preconnect"`);
    /*=>
    HTTPHeaderLink [
      ["https://example.com", { rel: "preconnect" }]
    ]
    */
  • new HTTPHeaderLink(`<https://example.com/%E8%8B%97%E6%9D%A1>; rel="preconnect"`);
    /*=>
    HTTPHeaderLink [
      ["https://example.com/苗条", { rel: "preconnect" }]
    ]
    */

About

An ECMAScript module to handle HTTP header `Link` according to RFC 8288 standard.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors