Actually, if you're splitting it anyways then the trailing slash will leave the last index as an empty string. e.g.
```javascript
'/a/b/c'.split('/') == ['', 'a', 'b', 'c'];
'/a/b/c/'.split('/') == ['', 'a', 'b', 'c', ''];
```
So might just do the `trailingSlash` after the `segments` and do the array lookup instead.