mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-29 14:00:05 +02:00
14 lines
379 B
TypeScript
14 lines
379 B
TypeScript
export function buildUrlWithDetachRole(mode: string | null) {
|
|
return cleanURL(new URL(window.location.href), mode)
|
|
}
|
|
|
|
export function cleanURL(url: URL, mode: string | null) {
|
|
let cleanPathname = url.pathname
|
|
.replace(/\/(detached|detacher)\/?$/, '')
|
|
.replace(/\/$/, '')
|
|
if (mode) {
|
|
cleanPathname += `/${mode}`
|
|
}
|
|
url.pathname = cleanPathname
|
|
return url
|
|
}
|