aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/search/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-20 15:01:17 +0200
committerChocobozzz <me@florianbigard.com>2021-10-20 15:26:38 +0200
commit400043b1be38cdd7bc39462fa6a545eea0bea03e (patch)
tree68f447d00e06f80bbe84bf38dac30005e66cf2e4 /server/controllers/api/search/shared
parentebe9b6b3f32d8432980854a51d28a8fb88fe62e5 (diff)
downloadPeerTube-400043b1be38cdd7bc39462fa6a545eea0bea03e.tar.gz
PeerTube-400043b1be38cdd7bc39462fa6a545eea0bea03e.tar.zst
PeerTube-400043b1be38cdd7bc39462fa6a545eea0bea03e.zip
Add ability to search by URL with query params
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}