Refactor url parsing to simplify the state-passing (introducing a struct) and add a path parser for future reusability.