Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Oct 29, 2023
1 parent 8960289 commit b538aeb
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions megalodon/src/parse_link_header.ts
Original file line number Diff line number Diff line change
@@ -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
})

Expand Down

0 comments on commit b538aeb

Please sign in to comment.