1
0
Fork 0
peertube/server/controllers/api/search/shared/utils.ts
2021-10-20 15:26:38 +02:00

16 lines
374 B
TypeScript

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()
}