func isValidResponse()

in Sources/UberAuth/Authorize/AuthorizationCodeResponseParser.swift [48:69]


    func isValidResponse(url: URL, matching redirectURI: String) -> Bool {
        guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
              let expectedComponents = URLComponents(string: redirectURI) else {
            return false
        }

        // Verify incoming scheme matches redirect_uri scheme
        guard let scheme = components.scheme?.lowercased(),
              let expectedScheme = expectedComponents.scheme?.lowercased(),
              scheme == expectedScheme else {
            return false
        }
        
        // Verify incoming host matches redirect_uri host
        guard let scheme = components.host?.lowercased(),
              let expectedScheme = expectedComponents.host?.lowercased(),
              scheme == expectedScheme else {
            return false
        }
                
        return true
    }