Files
boris/node_modules/applesauce-content/dist/helpers/media.js
Gigi 5d53a827e0 feat: initialize markr nostr bookmark client
- Add project structure with TypeScript, React, and Vite
- Implement nostr authentication using browser extension (NIP-07)
- Add NIP-51 compliant bookmark fetching and display
- Create minimal UI with login and bookmark components
- Integrate applesauce-core and applesauce-react libraries
- Add responsive styling with dark/light mode support
- Include comprehensive README with setup instructions

This is a minimal MVP for a nostr bookmark client that allows users to
view their bookmarks according to NIP-51 specification.
2025-10-02 07:17:07 +02:00

16 lines
700 B
JavaScript

import { getSha256FromURL } from "applesauce-core/helpers/file-metadata";
import { Tokens } from "./regexp.js";
/** Returns all URLs in a content string that contain a sha256 hash */
export function getMediaAttachmentURLsFromContent(content) {
return (Array.from(content.matchAll(Tokens.link))
.map((match) => match[0])
// filter out invalid URLs
.filter((str) => URL.canParse(str))
// convert to URLs
.map((url) => new URL(url))
// only keep urls with sha256 hashes in the
.filter((url) => !!getSha256FromURL(url))
// convert to media attachments
.map((url) => ({ url: url.toString(), sha256: getSha256FromURL(url) })));
}