diff --git a/src/composables/api.ts b/src/composables/api.ts index 5995527..706a20c 100644 --- a/src/composables/api.ts +++ b/src/composables/api.ts @@ -15,11 +15,11 @@ class NetworkError extends Error { * @returns */ function parseLinkHeader(link: string): LinkObject { - const [, uriRef, attrs] = link.match(/<(.+)>; (.+)/)!; + const [, uriRef, attrs] = link.match(/<(.+)>;\s?(.+)/)!; let linkObj: Partial = { uriRef }; - attrs.split("; ").forEach(l => { - const [, lhs, rhs] = l.match(/(.+)=[\"<](.+)[\">]/) as [string, keyof Omit, string]; + attrs.split(";").forEach(l => { + const [, lhs, rhs] = l.trim().match(/(.+)=[\"<](.+)[\">]/) as [string, keyof Omit, string]; linkObj[lhs] = rhs; }); @@ -60,7 +60,7 @@ async function individualApiRequest(url: string) { function getProfilesFromHeaders(link: string): ProfileHeader[] { let profileObj: {[uri: string]: ProfileHeader} = {} ; - const links = link.split(", ").map(l => parseLinkHeader(l)); + const links = link.split(",").map(l => parseLinkHeader(l.trim())); links.filter(l => l.rel === "type").forEach(l => { profileObj[l.anchor] = {