mirror of
https://github.com/dergigi/boris.git
synced 2026-01-03 23:14:36 +01:00
- 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.
16 lines
700 B
JavaScript
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) })));
|
|
}
|