Support embedding media from IPFS

This commit is contained in:
hzrd149 2024-05-20 15:52:30 -05:00
parent fef6880fe5
commit 3da4c3f6cd
2 changed files with 14 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
"nostrudel": patch
---
Support embedding media from IPFS

View File

@ -9,15 +9,21 @@ export function isMediaURL(url: string | URL) {
}
export function isImageURL(url: string | URL) {
const u = new URL(url);
return IMAGE_EXT.some((ext) => u.pathname.endsWith(ext));
const ipfsFilename = u.searchParams.get("filename");
return IMAGE_EXT.some((ext) => u.pathname.endsWith(ext) || ipfsFilename?.endsWith(ext));
}
export function isVideoURL(url: string | URL) {
const u = new URL(url);
return VIDEO_EXT.some((ext) => u.pathname.endsWith(ext));
const ipfsFilename = u.searchParams.get("filename");
return VIDEO_EXT.some((ext) => u.pathname.endsWith(ext) || ipfsFilename?.endsWith(ext));
}
export function isAudioURL(url: string | URL) {
const u = new URL(url);
return AUDIO_EXT.some((ext) => u.pathname.endsWith(ext));
const ipfsFilename = u.searchParams.get("filename");
return AUDIO_EXT.some((ext) => u.pathname.endsWith(ext) || ipfsFilename?.endsWith(ext));
}
export function replaceDomain(url: string | URL, replacementUrl: string | URL) {