Also, this code would be simpler (easier to reason about the part counts) if you remove the leading slash before splitting.