Skip to content

Instantly share code, notes, and snippets.

@radekcieciwa
Last active July 19, 2017 09:34
Show Gist options
  • Save radekcieciwa/82e5737ef4889c27a2e8492e64776088 to your computer and use it in GitHub Desktop.
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
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