diff --git a/src/lib/parsing.ts b/src/lib/parsing.ts index 33bd0c1..aeae4b2 100644 --- a/src/lib/parsing.ts +++ b/src/lib/parsing.ts @@ -2,7 +2,9 @@ import { nip19 } from "@nostr-dev-kit/ndk"; // Regex patterns const URL_REGEX = /https?:\/\/[^\s<>"')\]]+/g; -const IMAGE_EXTENSIONS = /\.(jpg|jpeg|png|gif|webp|svg)(\?[^\s]*)?$/i; +const IMAGE_EXTENSIONS = /\.(jpg|jpeg|jpg2|jp2|jpe|png|gif|webp|svg|avif|bmp|tiff?)(\?[^\s]*)?$/i; +// Blossom / NIP-96 content-addressed URLs: SHA-256 hash (64 hex) as filename, any extension +const BLOSSOM_URL_REGEX = /\/[0-9a-f]{64}(\.[a-z0-9]{0,5})?$/i; const VIDEO_EXTENSIONS = /\.(mp4|webm|mov|ogg|m4v|avi)(\?[^\s]*)?$/i; const AUDIO_EXTENSIONS = /\.(mp3|wav|flac|aac|m4a|opus|ogg)(\?[^\s]*)?$/i; const YOUTUBE_REGEX = /(?:youtube\.com\/(?:watch\?v=|embed\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/; @@ -37,7 +39,7 @@ export function parseContent(content: string): ContentSegment[] { // Clean trailing punctuation that's likely not part of the URL const cleaned = url.replace(/[.,;:!?)]+$/, ""); - if (IMAGE_EXTENSIONS.test(cleaned)) { + if (IMAGE_EXTENSIONS.test(cleaned) || BLOSSOM_URL_REGEX.test(cleaned)) { allMatches.push({ index: match.index, length: cleaned.length,