I need to make https://example.com/page/name/ -> /page/name I wrote function like this:
rewriteUrl (url) {
    let chunks = url.split('/')
    chunks.splice(0, 3)
    chunks.unshift('')
    chunks = chunks.join('/')
    if (chunks.split('').pop() === '/') chunks = chunks.slice(0, -1)
    return chunks
  }
but you see it looks enigmatically. Can you refactor to something groovy?
 
     
    