type alias CanonicalizeSource

Optional export, parallel to pluginOptions. Given a URL this plugin's site might expose (any domain alias, with or without query string/trailing slash/scheme), returns the canonical form the host should use for matching against stored source: tags — e.g. e-hentai folding exhentai.org/g.e-hentai.org/forums.e-hentai.org all down to a single e-hentai.org/g/{gid}/{token} form. The host calls this before every source: tag comparison (both for DownloadResult.version_history matching and for plugins/script/sourcefinder.ts's existing lookup) instead of maintaining its own per-site domain-alias table, so this plugin's own domain-alias knowledge lives in the one place that actually has it.

CONTRACT (required, not just a suggestion): this function MUST be idempotent and MUST produce byte-identical output for every URL form that refers to the same underlying resource — including a URL already stored in an archive's source: tag from a PAST version of this plugin (or from the host's own generic trim_url()), a freshly-fetched URL this plugin just resolved via execDownload, AND every entry this plugin puts in DownloadResult.version_history[].source. The host calls this function on both sides of every comparison and does a plain string equality check on the results — if this function ever normalizes the same real-world resource into two different strings depending on which historical form of the URL it was given, the comparison silently fails to match with no error surfaced anywhere, which is far harder to diagnose than an exception. When in doubt, normalize toward the most stable identifier the site guarantees never changes (e.g. e-hentai's numeric gid), not toward whatever the most recently observed URL shape happens to look like.

Return the input unchanged if this plugin has no additional normalization beyond the host's generic scheme/www/query/trailing-slash trimming. Omitting this export entirely is valid — the host then applies only its own generic trim_url().

This declaration exists purely to document the contract; a plugin declares its own export function canonicalizeSource(url: string): string rather than importing this type.

Definition

(url: string) => string

Usage

import { type CanonicalizeSource } from "crates/lanrurugi-plugin/dispatcher/plugin-sdk.ts";