bankcode-bic
Version:
Convert bank codes from IBAN to BICs, Name of bank. Currently supports only some selected EU countries.
17 lines (16 loc) • 573 B
JavaScript
//#region src/libs/scrape-dowload-url.ts
const scrapeDownloadUrl = async (websiteUrl, urlRegex, fetchFn) => {
const response = await fetchFn(websiteUrl);
if (!response.ok) throw new Error(`Failed to fetch ${websiteUrl}: ${response.statusText}`);
const text = await response.text();
const match = text.match(urlRegex);
if (!match || !match.groups) throw new Error(`No matching URL found in ${websiteUrl}`);
const { url, version } = match.groups;
return {
websiteUrl,
url: new URL(url, websiteUrl).href,
version
};
};
//#endregion
export { scrapeDownloadUrl };