From 71e3e879c0616882ee82a0e44f8c2e5ee9698a3e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 2 Dec 2022 14:47:21 +0100 Subject: Support reinjecting token in private m3u8 playlist --- shared/core-utils/common/url.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'shared/core-utils') diff --git a/shared/core-utils/common/url.ts b/shared/core-utils/common/url.ts index d1c399f7b..33fc5ee3a 100644 --- a/shared/core-utils/common/url.ts +++ b/shared/core-utils/common/url.ts @@ -11,6 +11,14 @@ function addQueryParams (url: string, params: { [ id: string ]: string }) { return objUrl.toString() } +function removeQueryParams (url: string) { + const objUrl = new URL(url) + + objUrl.searchParams.forEach((_v, k) => objUrl.searchParams.delete(k)) + + return objUrl.toString() +} + function buildPlaylistLink (playlist: Pick, base?: string) { return (base ?? window.location.origin) + buildPlaylistWatchPath(playlist) } @@ -114,6 +122,7 @@ function decoratePlaylistLink (options: { export { addQueryParams, + removeQueryParams, buildPlaylistLink, buildVideoLink, -- cgit v1.2.3