mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-10-01 17:31:13 +00:00
Add support for unified addresses
This commit is contained in:
parent
4e22957391
commit
dcf32be914
@ -16,6 +16,7 @@ import {
|
||||
isSpotify,
|
||||
isTagMention,
|
||||
isTwitch,
|
||||
isUnitifedLnAddress,
|
||||
isUrl,
|
||||
isUserMention,
|
||||
isWavelake,
|
||||
@ -41,7 +42,7 @@ import { hookForDev } from '../../lib/devTools';
|
||||
import { getMediaUrl as getMediaUrlDefault } from "../../lib/media";
|
||||
import NoteImage from '../NoteImage/NoteImage';
|
||||
import { createStore, unwrap } from 'solid-js/store';
|
||||
import { hashtagCharsRegex, Kind, linebreakRegex, shortMentionInWords, shortNoteWords, specialCharsRegex, urlExtractRegex } from '../../constants';
|
||||
import { hashtagCharsRegex, Kind, linebreakRegex, lnUnifiedRegex, shortMentionInWords, shortNoteWords, specialCharsRegex, urlExtractRegex } from '../../constants';
|
||||
import { useIntl } from '@cookbook/solid-intl';
|
||||
import { actions } from '../../translations';
|
||||
|
||||
@ -398,6 +399,20 @@ const ParsedNote: Component<{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isUnitifedLnAddress(token)) {
|
||||
lastSignificantContent = 'lnbc';
|
||||
|
||||
const match = token.match(lnUnifiedRegex);
|
||||
|
||||
let lnbcToken = match?.find(m => m.startsWith('lnbc'));
|
||||
|
||||
lnbcToken ?
|
||||
updateContent(content, 'lnbc', lnbcToken) :
|
||||
updateContent(content, 'text', token);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (isLnbc(token)) {
|
||||
lastSignificantContent = 'lnbc';
|
||||
updateContent(content, 'lnbc', token);
|
||||
|
@ -258,6 +258,7 @@ export const urlExtractRegex = /https?:\/\/\S+\.[^()]+(?:\([^)]*\))*/;
|
||||
export const interpunctionRegex = /^(\.|,|;|\?|\!)$/;
|
||||
export const emojiRegex = /(?:\s|^)\:\w+\:/;
|
||||
export const lnRegex = /lnbc[a-zA-Z0-9]*/;
|
||||
export const lnUnifiedRegex = /bitcoin:[a-zA-Z0-9]*(\?.*)lightning=([a-zA-Z0-9]*)(&.*|$)/;
|
||||
|
||||
export const hashtagRegex = /(?:\s|^)#[^\s!@#$%^&*(),.?":{}|<>]+/i;
|
||||
export const linebreakRegex = /(\r\n|\r|\n)/ig;
|
||||
|
@ -3,7 +3,7 @@ import { A } from "@solidjs/router";
|
||||
import { Relay, relayInit } from "nostr-tools";
|
||||
import { createStore } from "solid-js/store";
|
||||
import LinkPreview from "../components/LinkPreview/LinkPreview";
|
||||
import { appleMusicRegex, emojiRegex, hashtagRegex, interpunctionRegex, Kind, linebreakRegex, lnRegex, mixCloudRegex, nostrNestsRegex, noteRegex, noteRegexLocal, profileRegex, profileRegexG, soundCloudRegex, spotifyRegex, tagMentionRegex, twitchRegex, urlRegex, urlRegexG, wavlakeRegex, youtubeRegex } from "../constants";
|
||||
import { appleMusicRegex, emojiRegex, hashtagRegex, interpunctionRegex, Kind, linebreakRegex, lnRegex, lnUnifiedRegex, mixCloudRegex, nostrNestsRegex, noteRegex, noteRegexLocal, profileRegex, profileRegexG, soundCloudRegex, spotifyRegex, tagMentionRegex, twitchRegex, urlRegex, urlRegexG, wavlakeRegex, youtubeRegex } from "../constants";
|
||||
import { sendMessage, subscribeTo } from "../sockets";
|
||||
import { MediaSize, NostrRelays, NostrRelaySignedEvent, PrimalNote, SendNoteResult } from "../types/primal";
|
||||
import { logError, logInfo, logWarning } from "./logger";
|
||||
@ -61,6 +61,7 @@ export const isUserMention = (url: string) => profileRegex.test(url);
|
||||
export const isInterpunction = (url: string) => interpunctionRegex.test(url);
|
||||
export const isCustomEmoji = (url: string) => emojiRegex.test(url);
|
||||
export const isLnbc = (url: string) => lnRegex.test(url);
|
||||
export const isUnitifedLnAddress = (url: string) => lnUnifiedRegex.test(url);
|
||||
|
||||
export const isImage = (url: string) => ['.jpg', '.jpeg', '.webp', '.png', '.gif', '.format=png'].some(x => url.includes(x));
|
||||
export const isMp4Video = (url: string) => ['.mp4', '.mov'].some(x => url.includes(x));
|
||||
|
Loading…
Reference in New Issue
Block a user