diff options
Diffstat (limited to 'shared/core-utils')
-rw-r--r-- | shared/core-utils/common/url.ts | 12 |
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 @@ | |||
1 | import { Video, VideoPlaylist } from '../../models' | 1 | import { Video, VideoPlaylist } from '../../models' |
2 | import { secondsToTime } from './date' | 2 | import { secondsToTime } from './date' |
3 | 3 | ||
4 | function 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 | |||
4 | function buildPlaylistLink (playlist: Pick<VideoPlaylist, 'shortUUID'>, base?: string) { | 14 | function 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 | ||
105 | export { | 115 | export { |
116 | addQueryParams, | ||
117 | |||
106 | buildPlaylistLink, | 118 | buildPlaylistLink, |
107 | buildVideoLink, | 119 | buildVideoLink, |
108 | 120 | ||