1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 export const sanitizeToken = (href: string, tokenAsQueryParam: boolean = true): string => {
6 const [prefix, suffix] = href.split('/t=');
7 const [token, ...rest] = suffix.split('/');
9 return `${[prefix, ...rest].join('/')}${tokenAsQueryParam ? `?api_token=${token}` : ''}`;
12 export const getClipboardUrl = (href: string): string => {
13 const { origin } = window.location;
15 return `${origin}?redirectTo=${sanitizeToken(href, false)}`;