overleaf/services/web/frontend/js/shared/utils/url-helper.js
Timothée Alby 44eca312ff Merge pull request #6053 from overleaf/ta-pdf-detach-tests
PDF Detach Misc Tests

GitOrigin-RevId: 9615c8fdfd8964a9c63d7c91e4596d397a1d35dc
2021-12-15 09:04:46 +00:00

11 lines
287 B
JavaScript

export function buildUrlWithDetachRole(mode) {
const url = new URL(window.location)
let cleanPathname = url.pathname
.replace(/\/(detached|detacher)\/?$/, '')
.replace(/\/$/, '')
if (mode) {
cleanPathname += `/${mode}`
}
url.pathname = cleanPathname
return url
}