diff --git a/megalodon/src/parse_link_header.ts b/megalodon/src/parse_link_header.ts index 9eb49982c..ef2f11cf7 100644 --- a/megalodon/src/parse_link_header.ts +++ b/megalodon/src/parse_link_header.ts @@ -1,24 +1,21 @@ // Refs: https://gist.github.com/Honkalonkalooohhhhh/dfe8a3721f77ded62ff8038ead2afd77 export function parseLinkHeader(header: string): LinkHeader { - let parts: string[] - let links: LinkHeader = {} + const links: LinkHeader = {} if (header.length === 0) { throw new Error('input must not be of zero length') } - parts = header.split(',') + const parts = header.split(',') // Parse each part into a named link parts.forEach(part => { - let section: string[] = part.split(';') - let url: string - let name: string + const section: string[] = part.split(';') if (section.length !== 2) { throw new Error("section could not be split on ';'") } - url = section[0].replace(/<(.*)>/, '$1').trim() - name = section[1].replace(/rel="(.*)"/, '$1').trim() + const url = section[0].replace(/<(.*)>/, '$1').trim() + const name = section[1].replace(/rel="(.*)"/, '$1').trim() links[name] = url })