feat: add auto-load profile pictures setting (#712)

This commit is contained in:
gzuuus 2025-12-29 15:42:02 +01:00 committed by GitHub
parent ec03a49e32
commit 6dc662bd2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 170 additions and 47 deletions

View file

@ -23,7 +23,7 @@ export function determineExternalContentKind(externalContent: string): string |
if (externalContent.startsWith('podcast:publisher:guid:')) {
return 'podcast:publisher:guid'
}
// Handle blockchain transaction format: <blockchain>:[<chainId>:]tx:<txid>
// Match pattern: blockchain name, optional chain ID, "tx:", transaction ID
const blockchainTxMatch = externalContent.match(/^([a-z]+):(?:[^:]+:)?tx:[a-f0-9]+$/i)
@ -31,10 +31,12 @@ export function determineExternalContentKind(externalContent: string): string |
const blockchain = blockchainTxMatch[1].toLowerCase()
return `${blockchain}:tx`
}
// Handle blockchain address format: <blockchain>:[<chainId>:]address:<address>
// Match pattern: blockchain name, optional chain ID, "address:", address
const blockchainAddressMatch = externalContent.match(/^([a-z]+):(?:[^:]+:)?address:[a-zA-Z0-9]+$/i)
const blockchainAddressMatch = externalContent.match(
/^([a-z]+):(?:[^:]+:)?address:[a-zA-Z0-9]+$/i
)
if (blockchainAddressMatch) {
const blockchain = blockchainAddressMatch[1].toLowerCase()
return `${blockchain}:address`

View file

@ -51,4 +51,4 @@ export function getLightningAddressFromProfile(profile: TProfile) {
}
return lud16 || lud06 || undefined
}
}

View file

@ -7,25 +7,27 @@ export function parseEditorJsonToText(node?: JSONContent) {
const text = _parseEditorJsonToText(node)
const regex = /(^|\s+|@)(nostr:)?(nevent|naddr|nprofile|npub)1[a-zA-Z0-9]+/g
return text.replace(regex, (match, leadingWhitespace) => {
let bech32 = match.trim()
const whitespace = leadingWhitespace || ''
return text
.replace(regex, (match, leadingWhitespace) => {
let bech32 = match.trim()
const whitespace = leadingWhitespace || ''
if (bech32.startsWith('@nostr:')) {
bech32 = bech32.slice(7)
} else if (bech32.startsWith('@')) {
bech32 = bech32.slice(1)
} else if (bech32.startsWith('nostr:')) {
bech32 = bech32.slice(6)
}
if (bech32.startsWith('@nostr:')) {
bech32 = bech32.slice(7)
} else if (bech32.startsWith('@')) {
bech32 = bech32.slice(1)
} else if (bech32.startsWith('nostr:')) {
bech32 = bech32.slice(6)
}
try {
nip19.decode(bech32)
return `${whitespace}nostr:${bech32}`
} catch {
return match
}
}).trim()
try {
nip19.decode(bech32)
return `${whitespace}nostr:${bech32}`
} catch {
return match
}
})
.trim()
}
function _parseEditorJsonToText(node?: JSONContent): string {