Skip to content

Commit

Permalink
Rolled back the URL validation logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed May 3, 2019
1 parent 945564d commit 4a6e12e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion WordPressAuthenticator/Model/LoginFields+Validation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ extension LoginFields {
/// Returns *true* if the siteURL contains a valid URL. False otherwise.
///
func validateSiteForSignin() -> Bool {
return siteAddress.isValidURL()
guard let url = URL(string: NSURL.idnEncodedURL(siteAddress)) else {
return false
}

return !url.absoluteString.isEmpty
}

/// Returns *true* if the credentials required for account creation have been provided.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class LoginFieldsValidationTests: XCTestCase {
XCTAssertFalse(loginFields.validateSiteForSignin(), "Empty site should not validate.")

loginFields.siteAddress = "hostname"
XCTAssertFalse(loginFields.validateSiteForSignin(), "Since we want to validate simple mistakes, to use a hostname you'll need an http:// or https:// prefix.")
XCTAssertTrue(loginFields.validateSiteForSignin(), "Hostnames should validate.")

loginFields.siteAddress = "http://hostname"
XCTAssert(loginFields.validateSiteForSignin(), "Since we want to validate simple mistakes, to use a hostname you'll need an http:// or https:// prefix.")
Expand Down

0 comments on commit 4a6e12e

Please sign in to comment.