-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ConnectivityResponseValidator protocol and customValidator property #1
Conversation
// Abort early if enough tasks have completed successfully | ||
self?.cancelConnectivityCheck(pendingTasks: tasks, successfulChecks: successfulChecks, | ||
totalChecks: totalChecks) | ||
let completionHandlerForUrl: (URL) -> ((Data?, URLResponse?, Error?) -> Void) = { url in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To include the URL in response validation, the signature here was updated to require passing the URL, so that it could be captured and included when moving on to response validation
@@ -0,0 +1,60 @@ | |||
// | |||
// ConnectivityResponseValidation.swift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix the filename in the new PR
matchesRegularExpression | ||
} | ||
|
||
public class ConnectivityResponseStringTestValidator: ConnectivityResponseValidator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is the old validator renamed and given a public API
@@ -300,15 +305,31 @@ private extension Connectivity { | |||
} | |||
|
|||
/// Determines whether or not the connectivity check was successful. | |||
private func connectivityCheckSucceeded(data: Data?) -> Bool { | |||
guard let data = data, let responseString = String(data: data, encoding: .utf8) else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was moved into the validator
3f24d5d
to
fd36cf2
Compare
Closing this to reopen against main repo |
This is the initial implementation of rwbutler#26. I'll open a new PR with tests after some discussion + resolving rwbutler#27.