isn't this `url.rpartition('/')[0]`?