aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/search/shared
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/search/shared')
-rw-r--r--server/controllers/api/search/shared/index.ts1
-rw-r--r--server/controllers/api/search/shared/utils.ts16
2 files changed, 17 insertions, 0 deletions
diff --git a/server/controllers/api/search/shared/index.ts b/server/controllers/api/search/shared/index.ts
new file mode 100644
index 000000000..9c56149ef
--- /dev/null
+++ b/server/controllers/api/search/shared/index.ts
@@ -0,0 +1 @@
export * from './utils'
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 @@
1async 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
8export {
9 searchLocalUrl
10}
11
12// ---------------------------------------------------------------------------
13
14function removeQueryParams (url: string) {
15 return url.split('?').shift()
16}