aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/search/shared/utils.ts
blob: e02e84f3116617e7281b39d7fffb3c46088d9ca4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
async function searchLocalUrl <T> (url: string, finder: (url: string) => Promise<T>) {
  const data = await finder(url)
  if (data) return data

  return finder(removeQueryParams(url))
}

export {
  searchLocalUrl
}

// ---------------------------------------------------------------------------

function removeQueryParams (url: string) {
  return url.split('?').shift()
}