I think 2 exactly, since that defines service name and method name, I would suggest something like:

```ruby
path_components = env['PATH_INFO'].split("/").map { |x| CGI::unescape(x) }.compact
```

The `#compact` will remove nil entries from the array, which should leave you with the right number of components every time, regardless of leading or trailing slashes