UNPKG

@huggingface/hub

Version:

Utilities to interact with the Hugging Face hub

9 lines (7 loc) 364 B
/** * Parse Link HTTP header, eg `<https://huggingface.co/api/datasets/bigscience/P3/tree/main?recursive=1&cursor=...>; rel="next"` */ export function parseLinkHeader(header: string): Record<string, string> { const regex = /<(https?:[/][/][^>]+)>;\s+rel="([^"]+)"/g; return Object.fromEntries([...header.matchAll(regex)].map(([, url, rel]) => [rel, url])); }