Extract URL parsing logic, do it again on redirect