Leon4gr45's picture
Upload folder using huggingface_hub (part 5)
19e88d2 verified
Raw
History Blame Contribute Delete
364 Bytes
/**
* 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]));
}