parsing share link

This commit is contained in:
neon443 committed 2026-04-10 01:07:18 +01:00
1 parent 14841dded0
commit 38924dd246
1 file changed
+33 -7
@@ -14,12 +14,38 @@ struct EmojiPack: Identifiable, Codable {
var name: String
var description: String
var items: [String]
// var items: [EmojiPack.Item]
// var items: [EmojiPack.Item]
// struct Item: Identifiable, Codable, Equatable {
// var id: UUID
// var name: String
// }
// struct Item: Identifiable, Codable, Equatable {
// var id: UUID
// var name: String
// }
init(id: UUID, name: String, description: String, items: [String]) {
self.id = id
self.name = name
self.description = description
self.items = items
}
init(fromShareLink url: URL) {
guard var querySplit = url.query()?.split(separator: "&") else { fatalError() }
var queries: [String] = []
for split in querySplit {
if split.contains("%") {
queries.append(split.removingPercentEncoding!)
} else {
queries.append(String(split))
}
}
for query in queries {
print(query)
}
self.id = UUID()
self.name = ""
self.description = ""
self.items = []
}
mutating func add(_ newItem: String) {
guard !items.contains(newItem) else { return }
@@ -38,8 +64,7 @@ struct EmojiPack: Identifiable, Codable {
}
func shareLink() -> URL {
let scheme = URL(string: "stickerslack://")!
var url: URL = scheme.appendingPathComponent("pack", conformingTo: .directory)
var url = URL(string: "stickerslack://shared.pack/")!
let data = try! JSONEncoder().encode(items)
let queries: [URLQueryItem] = [
@@ -50,6 +75,7 @@ struct EmojiPack: Identifiable, Codable {
]
url = url.appending(queryItems: queries)
print(url.path(percentEncoded: true))
let _ = Self.init(fromShareLink: url)
return url
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.