diff --git a/public/index.html b/public/index.html
index db4da4b7..6e96cf6d 100644
--- a/public/index.html
+++ b/public/index.html
@@ -8,7 +8,7 @@
+ content="default-src 'self'; child-src 'none'; worker-src 'self'; frame-src youtube.com www.youtube.com https://platform.twitter.com https://embed.tidal.com https://w.soundcloud.com https://www.mixcloud.com https://open.spotify.com https://player.twitch.tv https://embed.music.apple.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src wss://* ws://*:* 'self' https://*; img-src * data:; font-src https://fonts.gstatic.com; media-src *; script-src 'self' https://static.cloudflareinsights.com https://platform.twitter.com https://embed.tidal.com;" />
diff --git a/src/Const.ts b/src/Const.ts
index 24801372..65365a0f 100644
--- a/src/Const.ts
+++ b/src/Const.ts
@@ -148,3 +148,9 @@ export const SpotifyRegex = /open\.spotify\.com\/(track|album|playlist|episode)\
* Twitch embed regex
*/
export const TwitchRegex = /twitch.tv\/([a-z0-9_]+$)/i;
+
+/**
+ * Apple Music embed regex
+ */
+export const AppleMusicRegex =
+ /music\.apple\.com\/([a-z]{2}\/)?(?:album|playlist)\/[\w\d-]+\/([.a-zA-Z0-9-]+)(?:\?i=\d+)?/i;
diff --git a/src/Element/AppleMusicEmbed.tsx b/src/Element/AppleMusicEmbed.tsx
new file mode 100644
index 00000000..bba7e2c9
--- /dev/null
+++ b/src/Element/AppleMusicEmbed.tsx
@@ -0,0 +1,16 @@
+const AppleMusicEmbed = ({ link }: { link: string }) => {
+ const convertedUrl = link.replace("music.apple.com", "embed.music.apple.com");
+ const isSongLink = /\?i=\d+$/.test(convertedUrl);
+
+ return (
+
+ );
+};
+
+export default AppleMusicEmbed;
diff --git a/src/Element/HyperText.tsx b/src/Element/HyperText.tsx
index 057812b1..78aada15 100644
--- a/src/Element/HyperText.tsx
+++ b/src/Element/HyperText.tsx
@@ -11,6 +11,7 @@ import {
MixCloudRegex,
SpotifyRegex,
TwitchRegex,
+ AppleMusicRegex,
} from "Const";
import { RootState } from "State/Store";
import SoundCloudEmbed from "Element/SoundCloudEmded";
@@ -20,6 +21,7 @@ import TidalEmbed from "Element/TidalEmbed";
import { ProxyImg } from "Element/ProxyImg";
import { HexKey } from "Nostr";
import TwitchEmbed from "./TwitchEmbed";
+import AppleMusicEmbed from "./AppleMusicEmbed";
export default function HyperText({ link, creator }: { link: string; creator: HexKey }) {
const pref = useSelector((s: RootState) => s.login.preferences);
@@ -44,10 +46,11 @@ export default function HyperText({ link, creator }: { link: string; creator: He
const tidalId = TidalRegex.test(a) && RegExp.$1;
const soundcloundId = SoundCloudRegex.test(a) && RegExp.$1;
const mixcloudId = MixCloudRegex.test(a) && RegExp.$1;
- const spotifyId = SpotifyRegex.test(a);
- const twitchId = TwitchRegex.test(a);
+ const isSpotifyLink = SpotifyRegex.test(a);
+ const isTwitchLink = TwitchRegex.test(a);
+ const isAppleMusicLink = AppleMusicRegex.test(a);
const extension = FileExtensionRegex.test(url.pathname.toLowerCase()) && RegExp.$1;
- if (extension) {
+ if (extension && !isAppleMusicLink) {
switch (extension) {
case "gif":
case "jpg":
@@ -110,10 +113,12 @@ export default function HyperText({ link, creator }: { link: string; creator: He
return ;
} else if (mixcloudId) {
return ;
- } else if (spotifyId) {
+ } else if (isSpotifyLink) {
return ;
- } else if (twitchId) {
+ } else if (isTwitchLink) {
return ;
+ } else if (isAppleMusicLink) {
+ return ;
} else {
return (
e.stopPropagation()} target="_blank" rel="noreferrer" className="ext">