Make oauth redirect url parsing a bit more robust