Last active
July 19, 2017 09:34
-
-
Save radekcieciwa/82e5737ef4889c27a2e8492e64776088 to your computer and use it in GitHub Desktop.
Answer is easy if you debug the code. But it can be tricky to catch by eye. Will it create a entity for this URL = "https://abc.com/aa" ? You can find an answer here: https://bugs.swift.org/browse/SR-2176
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
struct UniversalLink { | |
public enum Action { | |
case none | |
case landto | |
} | |
public let action: Action | |
// Will it create a entity for this URL = "https://abc.com/aa"? | |
public init?(url: URL) { | |
guard let action = UniversalLink.action(from: url.path) else { return nil } | |
self.action = action | |
} | |
private static func action(from path: String) -> Action? { | |
switch path { | |
case "/aa/landto": | |
return .landto | |
case "/aa/", "/aa": | |
return .none | |
default: | |
return nil | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment