The Uri class (to be exact the static methods "string", "segment" and "segments") is "context-aware", which means it returns information about the current request.
If you want information about the main request (or any other pending request), you can access that via the request object. For the main request, use: