url-helper.js 287 B

1234567891011
  1. export function buildUrlWithDetachRole(mode) {
  2. const url = new URL(window.location)
  3. let cleanPathname = url.pathname
  4. .replace(/\/(detached|detacher)\/?$/, '')
  5. .replace(/\/$/, '')
  6. if (mode) {
  7. cleanPathname += `/${mode}`
  8. }
  9. url.pathname = cleanPathname
  10. return url
  11. }