add embed, media utils, time utils, url utils

This commit is contained in:
plebeius.eth
2024-03-26 13:17:55 +01:00
parent 97e5c17c4d
commit 5620a68337
4 changed files with 147 additions and 106 deletions
+26
View File
@@ -0,0 +1,26 @@
export const getHostname = (url: string) => {
try {
return new URL(url).hostname.replace(/^www\./, '');
} catch (e) {
return '';
}
};
export const isValidURL = (url: string) => {
try {
new URL(url);
return true;
} catch {
return false;
}
};
export const copyShareLinkToClipboard = (subplebbitAddress: string, cid: string) => {
const shareLink = `https://pleb.bz/p/${subplebbitAddress}/c/${cid}`;
if (navigator.clipboard) {
navigator.clipboard.writeText(shareLink);
} else {
alert('Your browser does not support clipboard API');
}
};