damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit c582755246726a2e1d454c72aa837b77ccf6b632
parent 44a59e8d573bff31b95b15bac5a878a64350eb58
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 20 Mar 2023 08:52:16 -0600

Fix internal links opening in other nostr clients

This prevents internal links from opening in other nostr apps

Changelog-Fixed: Fixed internal links opening in other nostr clients

Diffstat:
Mdamus/Info.plist | 10++++++++++
Mdamus/Nostr/NostrLink.swift | 3+++
Mdamus/Views/NoteContentView.swift | 6+++---
3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/damus/Info.plist b/damus/Info.plist @@ -14,6 +14,16 @@ <string>nostr</string> </array> </dict> + <dict> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + <key>CFBundleURLName</key> + <string>io.damus</string> + <key>CFBundleURLSchemes</key> + <array> + <string>damus</string> + </array> + </dict> </array> <key>LSApplicationQueriesSchemes</key> <array> diff --git a/damus/Nostr/NostrLink.swift b/damus/Nostr/NostrLink.swift @@ -127,6 +127,9 @@ func decode_nostr_uri(_ s: String) -> NostrLink? { var uri = s.replacingOccurrences(of: "nostr://", with: "") uri = uri.replacingOccurrences(of: "nostr:", with: "") + uri = s.replacingOccurrences(of: "damus://", with: "") + uri = uri.replacingOccurrences(of: "damus:", with: "") + let parts = uri.split(separator: ":") .reduce(into: Array<String>()) { acc, str in guard let decoded = str.removingPercentEncoding else { diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift @@ -141,7 +141,7 @@ struct NoteContentView: View { func hashtag_str(_ htag: String) -> AttributedString { var attributedString = AttributedString(stringLiteral: "#\(htag)") - attributedString.link = URL(string: "nostr:t:\(htag)") + attributedString.link = URL(string: "damus:t:\(htag)") attributedString.foregroundColor = Color("DamusPurple") return attributedString } @@ -160,13 +160,13 @@ func mention_str(_ m: Mention, profiles: Profiles) -> AttributedString { let profile = profiles.lookup(id: pk) let disp = Profile.displayName(profile: profile, pubkey: pk).username var attributedString = AttributedString(stringLiteral: "@\(disp)") - attributedString.link = URL(string: "nostr:\(encode_pubkey_uri(m.ref))") + attributedString.link = URL(string: "damus:\(encode_pubkey_uri(m.ref))") attributedString.foregroundColor = Color("DamusPurple") return attributedString case .event: let bevid = bech32_note_id(m.ref.ref_id) ?? m.ref.ref_id var attributedString = AttributedString(stringLiteral: "@\(abbrev_pubkey(bevid))") - attributedString.link = URL(string: "nostr:\(encode_event_id_uri(m.ref))") + attributedString.link = URL(string: "damus:\(encode_event_id_uri(m.ref))") attributedString.foregroundColor = Color("DamusPurple") return attributedString }