diff options
Diffstat (limited to 'server/controllers/api/search/shared/utils.ts')
-rw-r--r-- | server/controllers/api/search/shared/utils.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/server/controllers/api/search/shared/utils.ts b/server/controllers/api/search/shared/utils.ts new file mode 100644 index 000000000..e02e84f31 --- /dev/null +++ b/server/controllers/api/search/shared/utils.ts | |||
@@ -0,0 +1,16 @@ | |||
1 | async function searchLocalUrl <T> (url: string, finder: (url: string) => Promise<T>) { | ||
2 | const data = await finder(url) | ||
3 | if (data) return data | ||
4 | |||
5 | return finder(removeQueryParams(url)) | ||
6 | } | ||
7 | |||
8 | export { | ||
9 | searchLocalUrl | ||
10 | } | ||
11 | |||
12 | // --------------------------------------------------------------------------- | ||
13 | |||
14 | function removeQueryParams (url: string) { | ||
15 | return url.split('?').shift() | ||
16 | } | ||