Skip to main content

Protocol handler

import * as mod from "jsr:@nzip/lofi/recipes/protocol-handler";

Opt-in parser for a narrow custom-protocol collaborative-list deep link.

parseCollaborativeListProtocolTarget

function

function parseCollaborativeListProtocolTarget(search: string | URLSearchParams, options: ParseCollaborativeListProtocolOptions): CollaborativeListProtocolResult

Decode the handler query once and allow-list one collaborative-list item.

Expected payload: web+scheme:collaborative-list/LIST_ID/item/ITEM_ID. IDs are restricted to portable unreserved characters, and the result contains identifiers only. The received URL is never returned or used as a redirect.

CollaborativeListProtocolIssue

type

type CollaborativeListProtocolIssue =
| "missing-target"
| "duplicate-target"
| "unexpected-parameter"
| "target-too-long"
| "invalid-target"
| "wrong-protocol"
| "unsupported-shape"
| "invalid-list-id"
| "invalid-item-id";

Stable rejection that never contains the received protocol URL.

CollaborativeListProtocolResult

type

type CollaborativeListProtocolResult = { ok: true; target: CollaborativeListProtocolTarget } | { ok: false; issue: CollaborativeListProtocolIssue };

Accepted item reference or value-free rejection.

CollaborativeListProtocolTarget

type

type CollaborativeListProtocolTarget = {
readonly listId: string;
readonly itemId: string;
};

A validated collaborative-list item reference, never an arbitrary redirect.

ParseCollaborativeListProtocolOptions

type

type ParseCollaborativeListProtocolOptions = {
protocol: string;
parameter?: string;
maxLength?: number;
};

Options matching one protocol_handlers manifest entry.