aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/core-utils
diff options
context:
space:
mode:
Diffstat (limited to 'shared/core-utils')
-rw-r--r--shared/core-utils/common/url.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/shared/core-utils/common/url.ts b/shared/core-utils/common/url.ts
index fd54e7594..d1c399f7b 100644
--- a/shared/core-utils/common/url.ts
+++ b/shared/core-utils/common/url.ts
@@ -1,6 +1,16 @@
1import { Video, VideoPlaylist } from '../../models' 1import { Video, VideoPlaylist } from '../../models'
2import { secondsToTime } from './date' 2import { secondsToTime } from './date'
3 3
4function addQueryParams (url: string, params: { [ id: string ]: string }) {
5 const objUrl = new URL(url)
6
7 for (const key of Object.keys(params)) {
8 objUrl.searchParams.append(key, params[key])
9 }
10
11 return objUrl.toString()
12}
13
4function buildPlaylistLink (playlist: Pick<VideoPlaylist, 'shortUUID'>, base?: string) { 14function buildPlaylistLink (playlist: Pick<VideoPlaylist, 'shortUUID'>, base?: string) {
5 return (base ?? window.location.origin) + buildPlaylistWatchPath(playlist) 15 return (base ?? window.location.origin) + buildPlaylistWatchPath(playlist)
6} 16}
@@ -103,6 +113,8 @@ function decoratePlaylistLink (options: {
103// --------------------------------------------------------------------------- 113// ---------------------------------------------------------------------------
104 114
105export { 115export {
116 addQueryParams,
117
106 buildPlaylistLink, 118 buildPlaylistLink,
107 buildVideoLink, 119 buildVideoLink,
108 120