An ECMAScript module to handle the HTTP header Link according to the specification RFC 8288.
| Runtime \ Source | GitHub Raw | JSR | NPM |
|---|---|---|---|
| Bun >= v1.1.0 | ❌ | ✔️ | ✔️ |
| Deno >= v2.1.0 | ✔️ | ✔️ | ✔️ |
| NodeJS >= v20.9.0 | ❌ | ✔️ | ✔️ |
This does not request any runtime permission.
- 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).
- Benchmark/Test file (e.g.:
| Name | Path | Description |
|---|---|---|
. |
./mod.ts |
Default. |
-
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
- For the full or prettier documentation, can visit via:
-
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" }] ] */