-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change returnURL type from URL to String pattern
- Loading branch information
Andrei Solovev
committed
Mar 20, 2024
1 parent
39ab641
commit 83cee97
Showing
7 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import Foundation | ||
|
||
enum AppDeeplink: String { | ||
case threeDSChallenge = "omise_3ds_challenge" | ||
case threeDSChallenge = "3ds_challenge" | ||
|
||
var scheme: String { | ||
"omiseExampleApp" | ||
} | ||
|
||
var urlString: String { | ||
"\(scheme)://\(rawValue)" | ||
} | ||
|
||
var url: URL? { | ||
URL(string: "\(scheme)://\(rawValue)") | ||
URL(string: urlString) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Foundation | ||
|
||
extension URL { | ||
func match(string: String) -> Bool { | ||
guard | ||
let expectedURLComponents = URLComponents(string: string), | ||
let components = URLComponents(url: self, resolvingAgainstBaseURL: false) else { | ||
return false | ||
} | ||
|
||
return expectedURLComponents.match(components: components) | ||
} | ||
} | ||
|
||
extension URLComponents { | ||
func match(string: String) -> Bool { | ||
guard let expectedURLComponents = URLComponents(string: string) else { return false } | ||
return match(components: expectedURLComponents) | ||
} | ||
|
||
func match(components expectedURLComponents: URLComponents) -> Bool { | ||
return expectedURLComponents.scheme?.lowercased() == scheme?.lowercased() | ||
&& expectedURLComponents.host?.lowercased() == host?.lowercased() | ||
&& path.lowercased().hasPrefix(expectedURLComponents.path.lowercased()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters