mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-25 11:13:30 +02:00
fix url regexp in note content
This commit is contained in:
@@ -47,7 +47,8 @@ const embeds: EmbedType[] = [
|
|||||||
},
|
},
|
||||||
// Twitter tweet
|
// Twitter tweet
|
||||||
{
|
{
|
||||||
regexp: /https?:\/\/twitter\.com\/(?:\#!\/)?(\w+)\/status(es)?\/(\d+)[^\s]*/im,
|
regexp:
|
||||||
|
/https?:\/\/twitter\.com\/(?:\#!\/)?(\w+)\/status(es)?\/(\d+)(\??(?:[\?#\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/im,
|
||||||
render: (match) => <TweetEmbed href={match[0]} conversation={false} />,
|
render: (match) => <TweetEmbed href={match[0]} conversation={false} />,
|
||||||
name: "Tweet",
|
name: "Tweet",
|
||||||
isMedia: true,
|
isMedia: true,
|
||||||
@@ -96,7 +97,7 @@ const embeds: EmbedType[] = [
|
|||||||
},
|
},
|
||||||
// Youtube Music
|
// Youtube Music
|
||||||
{
|
{
|
||||||
regexp: /https?:\/\/music\.youtube\.com\/watch\?v=(\w+)[^\s]*/,
|
regexp: /https?:\/\/music\.youtube\.com\/watch\?v=(\w+)(\??(?:[\?#\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/,
|
||||||
render: (match) => (
|
render: (match) => (
|
||||||
<AspectRatio ratio={16 / 10} maxWidth="30rem">
|
<AspectRatio ratio={16 / 10} maxWidth="30rem">
|
||||||
<iframe
|
<iframe
|
||||||
@@ -128,7 +129,8 @@ const embeds: EmbedType[] = [
|
|||||||
// Spotify
|
// Spotify
|
||||||
// note12xt2pjpwp6gec95p4cw0qzecy764f8wzgcl3z2ufkrkne4t5d2zse3ze78
|
// note12xt2pjpwp6gec95p4cw0qzecy764f8wzgcl3z2ufkrkne4t5d2zse3ze78
|
||||||
{
|
{
|
||||||
regexp: /https?:\/\/open\.spotify\.com\/(track|episode|album|playlist)\/(\w+)[^\s]*/im,
|
regexp:
|
||||||
|
/https?:\/\/open\.spotify\.com\/(track|episode|album|playlist)\/(\w+)(\??(?:[\?#\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/im,
|
||||||
render: (match) => {
|
render: (match) => {
|
||||||
const isList = match[1] === "album" || match[1] === "playlist";
|
const isList = match[1] === "album" || match[1] === "playlist";
|
||||||
return (
|
return (
|
||||||
@@ -152,7 +154,7 @@ const embeds: EmbedType[] = [
|
|||||||
// note1tvqk2mu829yr6asf7w5dgpp8t0mlp2ax5t26ctfdx8m0ptkssamqsleeux
|
// note1tvqk2mu829yr6asf7w5dgpp8t0mlp2ax5t26ctfdx8m0ptkssamqsleeux
|
||||||
// note1ygx9tec3af92704d92jwrj3zs7cws2jl29yvrlxzqlcdlykhwssqpupa7t
|
// note1ygx9tec3af92704d92jwrj3zs7cws2jl29yvrlxzqlcdlykhwssqpupa7t
|
||||||
{
|
{
|
||||||
regexp: /https?:\/\/music\.apple\.com\/[^\s]*/im,
|
regexp: /https?:\/\/music\.apple\.com(?:\/[\+~%\/\.\w\-_]*)?(\??(?:[\?#\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/,
|
||||||
render: (match) => (
|
render: (match) => (
|
||||||
<iframe
|
<iframe
|
||||||
allow="encrypted-media *; fullscreen *; clipboard-write"
|
allow="encrypted-media *; fullscreen *; clipboard-write"
|
||||||
@@ -167,8 +169,10 @@ const embeds: EmbedType[] = [
|
|||||||
isMedia: true,
|
isMedia: true,
|
||||||
},
|
},
|
||||||
// Image
|
// Image
|
||||||
|
// note1n06jceulg3gukw836ghd94p0ppwaz6u3mksnnz960d8vlcp2fnqsgx3fu9
|
||||||
{
|
{
|
||||||
regexp: /(https?:\/\/)([\da-z\.-]+\.[a-z\.]{2,6})([\/\w\.-]+\.(svg|gif|png|jpg|jpeg|webp|avif))[^\s]*/im,
|
regexp:
|
||||||
|
/https?:\/\/([\dA-z\.-]+\.[A-z\.]{2,6})((?:\/[\+~%\/\.\w\-_]*)?\.(?:svg|gif|png|jpg|jpeg|webp|avif))(\??(?:[\?#\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/,
|
||||||
render: (match, event, trusted) => {
|
render: (match, event, trusted) => {
|
||||||
const ImageComponent = trusted || !settings.blurImages.value ? Image : BlurredImage;
|
const ImageComponent = trusted || !settings.blurImages.value ? Image : BlurredImage;
|
||||||
return <ImageComponent src={match[0]} width="100%" maxWidth="30rem" />;
|
return <ImageComponent src={match[0]} width="100%" maxWidth="30rem" />;
|
||||||
@@ -178,14 +182,18 @@ const embeds: EmbedType[] = [
|
|||||||
},
|
},
|
||||||
// Video
|
// Video
|
||||||
{
|
{
|
||||||
regexp: /(https?:\/\/)([\da-z\.-]+\.[a-z\.]{2,6})([\/\w\.-]+\.(mp4|mkv|webm|mov))[^\s]*/im,
|
regexp:
|
||||||
|
/https?:\/\/([\dA-z\.-]+\.[A-z\.]{2,6})((?:\/[\+~%\/\.\w\-_]*)?\.(?:mp4|mkv|webm|mov))(\??(?:[\?#\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/,
|
||||||
render: (match) => <video src={match[0]} controls style={{ maxWidth: "30rem", maxHeight: "20rem" }} />,
|
render: (match) => <video src={match[0]} controls style={{ maxWidth: "30rem", maxHeight: "20rem" }} />,
|
||||||
name: "Video",
|
name: "Video",
|
||||||
isMedia: true,
|
isMedia: true,
|
||||||
},
|
},
|
||||||
// Link
|
// Link
|
||||||
|
// based on http://urlregex.com/
|
||||||
|
// note1c34vht0lu2qzrgr4az3u8jn5xl3fycr2gfpahkepthg7hzlqg26sr59amt
|
||||||
{
|
{
|
||||||
regexp: /(https?:\/\/[^\s]*)/im,
|
regexp:
|
||||||
|
/https?:\/\/([\dA-z\.-]+\.[A-z\.]{2,6})((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/,
|
||||||
render: (match) => (
|
render: (match) => (
|
||||||
<Link color="blue.500" href={match[0]} target="_blank" isExternal>
|
<Link color="blue.500" href={match[0]} target="_blank" isExternal>
|
||||||
{match[0]}
|
{match[0]}
|
||||||
|
@@ -35,7 +35,12 @@ class ClientRelayService {
|
|||||||
lastSubject = undefined;
|
lastSubject = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastSubject = userRelaysService.requestRelays(account.pubkey, Array.from(this.bootstrapRelays), true);
|
// load the relays from cache or bootstrap relays
|
||||||
|
lastSubject = userRelaysService.requestRelays(account.pubkey, Array.from(this.bootstrapRelays));
|
||||||
|
setTimeout(() => {
|
||||||
|
// double check for new relay notes
|
||||||
|
userRelaysService.requestRelays(account.pubkey, this.getWriteUrls(), true);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
lastSubject.subscribe(this.handleRelayChanged, this);
|
lastSubject.subscribe(this.handleRelayChanged, this);
|
||||||
});
|
});
|
||||||
|
@@ -22,6 +22,7 @@ import { RelayConfig, RelayMode } from "../../classes/relay";
|
|||||||
import { useList } from "react-use";
|
import { useList } from "react-use";
|
||||||
import { RelayUrlInput } from "../../components/relay-url-input";
|
import { RelayUrlInput } from "../../components/relay-url-input";
|
||||||
import useSubject from "../../hooks/use-subject";
|
import useSubject from "../../hooks/use-subject";
|
||||||
|
import { RelayStatus } from "../../components/relay-status";
|
||||||
|
|
||||||
export const RelaysView = () => {
|
export const RelaysView = () => {
|
||||||
const relays = useSubject(clientRelaysService.relays);
|
const relays = useSubject(clientRelaysService.relays);
|
||||||
@@ -71,6 +72,7 @@ export const RelaysView = () => {
|
|||||||
<Thead>
|
<Thead>
|
||||||
<Tr>
|
<Tr>
|
||||||
<Th>Url</Th>
|
<Th>Url</Th>
|
||||||
|
<Th>Status</Th>
|
||||||
<Th></Th>
|
<Th></Th>
|
||||||
</Tr>
|
</Tr>
|
||||||
</Thead>
|
</Thead>
|
||||||
@@ -83,6 +85,9 @@ export const RelaysView = () => {
|
|||||||
<Text>{relay.url}</Text>
|
<Text>{relay.url}</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Td>
|
</Td>
|
||||||
|
<Td>
|
||||||
|
<RelayStatus url={relay.url} />
|
||||||
|
</Td>
|
||||||
<Td isNumeric>
|
<Td isNumeric>
|
||||||
{pendingAdd.includes(relay) && (
|
{pendingAdd.includes(relay) && (
|
||||||
<Badge colorScheme="green" mr="2">
|
<Badge colorScheme="green" mr="2">
|
||||||
|
Reference in New Issue
Block a user