@@ -8,6 +8,7 @@ import net.primal.android.user.domain.isNwcUrl
8
8
import net.primal.android.user.domain.parseNWCUrl
9
9
10
10
private val PRIMAL_NOTE_REGEX = Regex (" https://.*primal.net/e/" )
11
+ private val PRIMAL_PROFILE_REGEX = Regex (" https://.*primal.net/p/" )
11
12
12
13
private const val NOSTR_WALLET_CONNECT_SCHEMA = " nostr+walletconnect://"
13
14
private const val NOSTR_WALLET_CONNECT_ALT_SCHEMA = " nostrwalletconnect://"
@@ -22,6 +23,11 @@ fun String.parseDeepLinkOrNull(): DeepLink? =
22
23
unknownNoteIdentifier.resolveNoteId()?.let { DeepLink .Note (it) }
23
24
}
24
25
26
+ PRIMAL_PROFILE_REGEX .containsMatchIn(this ) -> {
27
+ val unknownProfileIdentifier = PRIMAL_PROFILE_REGEX .replace(this , " " )
28
+ unknownProfileIdentifier.resolveProfileId()?.let { DeepLink .Profile (it) }
29
+ }
30
+
25
31
isNostrWalletConnectSchemaAndUrl() ->
26
32
runCatching {
27
33
DeepLink .NostrWalletConnect (nwc = this .parseNWCUrl())
@@ -35,6 +41,16 @@ fun String.parseDeepLinkOrNull(): DeepLink? =
35
41
else -> null
36
42
}
37
43
44
+ private fun String.resolveProfileId (): String? =
45
+ when {
46
+ this .startsWith(" npub" ) -> runCatching { bech32ToHexOrThrow() }.getOrNull()
47
+ this .startsWith(" nprofile1" ) -> {
48
+ val pubkey = Nip19TLV .parseUriAsNprofileOrNull(this )?.pubkey
49
+ runCatching { pubkey?.bech32ToHexOrThrow() }.getOrNull()
50
+ }
51
+ else -> this
52
+ }
53
+
38
54
private fun String.resolveNoteId (): String? =
39
55
when {
40
56
this .startsWith(" note1" ) -> runCatching { bech32ToHexOrThrow() }.getOrNull()
0 commit comments