updates plug with all sorts of awesome improvements
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import Foundation
|
||||
|
||||
/// What a `plak://` URL from another app asks for: append its text, or append the pasteboard.
|
||||
public enum URLCommand: Equatable, Sendable {
|
||||
case append(String)
|
||||
case paste
|
||||
|
||||
/// Reads `plak://append?text=…` and `plak://paste`; any other URL gives nil.
|
||||
public init?(_ url: URL) {
|
||||
guard url.scheme?.lowercased() == "plak", let components = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return nil }
|
||||
switch components.host?.lowercased() {
|
||||
case "append":
|
||||
self = .append(components.queryItems?.first { $0.name == "text" }?.value ?? "")
|
||||
case "paste":
|
||||
self = .paste
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user