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
This commit is contained in:
William Casarin
2023-03-20 08:52:16 -06:00
parent 44a59e8d57
commit c582755246
3 changed files with 16 additions and 3 deletions

View File

@@ -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>

View File

@@ -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 {

View File

@@ -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
}