Update Wavlake embed URL, add support for album & artist links (#439)

* Update wavlake embed url

* Make regex more explicit, remove allow from iframe

* Prettify changes
This commit is contained in:
Michael Rhee 2023-03-14 12:07:59 -05:00 committed by GitHub
parent 877d018da3
commit 2b0cd75f98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -8,7 +8,7 @@
<meta name="description" content="Fast nostr web ui" />
<meta
http-equiv="Content-Security-Policy"
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 https://nostrnests.com https://player.wavlake.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src *; img-src * data:; font-src https://fonts.gstatic.com; media-src *; script-src 'self' 'wasm-unsafe-eval' https://static.cloudflareinsights.com https://platform.twitter.com https://embed.tidal.com;" />
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 https://nostrnests.com https://embed.wavlake.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src *; img-src * data:; font-src https://fonts.gstatic.com; media-src *; script-src 'self' 'wasm-unsafe-eval' https://static.cloudflareinsights.com https://platform.twitter.com https://embed.tidal.com;" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />

View File

@ -168,4 +168,5 @@ export const MagnetRegex = /(magnet:[\S]+)/i;
/**
* Wavlake embed regex
*/
export const WavlakeRegex = /player\.wavlake\.com\/(track)\/([.a-zA-Z0-9-]+)/;
export const WavlakeRegex =
/player\.wavlake\.com\/(?!feed\/)(track\/[.a-zA-Z0-9-]+|album\/[.a-zA-Z0-9-]+|[.a-zA-Z0-9-]+)/i;

View File

@ -1,14 +1,13 @@
const WavlakeEmbed = ({ link }: { link: string }) => {
const convertedUrl = link.replace(/\/(track)\/([a-zA-Z0-9]+)/, "/embed/$1/$2");
const convertedUrl = link.replace("player.wavlake.com", "embed.wavlake.com");
return (
<iframe
style={{ borderRadius: 12 }}
src={convertedUrl}
width="100%"
height="360"
height="380"
frameBorder="0"
allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"
loading="lazy"></iframe>
);
};