Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

@url-sanitize/fetch

Runtime ClearURLs catalog fetching with SHA256 verification and optional consumer-side hash pinning.

This package intentionally fetches only ClearURLs at runtime. For the bundled default multi-source behavior, use @url-sanitize/merged.

Install

npm install @url-sanitize/fetch @url-sanitize/core

Usage

import { fetchClearurlsCatalog } from '@url-sanitize/fetch';
import { compileSanitizer } from '@url-sanitize/core';

const { catalog, metadata } = await fetchClearurlsCatalog({
  pinnedHash: process.env.CLEARURLS_RULES_HASH
});

const sanitize = compileSanitizer(catalog);
console.log(metadata.hash);
console.log(sanitize('https://example.com/?utm_source=x'));

pinnedHash is optional. When set, the downloaded rules must match both the upstream rules.minify.hash and the consumer-provided pin. timeoutMs defaults to 10000 and bounds each rules/hash request.

License

MIT.