url-helper.js 288 B

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