2024-03-26 13:17:55 +01:00
|
|
|
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) => {
|
2024-05-27 18:42:31 +02:00
|
|
|
const shareLink = `https://pleb.bz/p/${subplebbitAddress}/c/${cid}?redirect=plebchan.eth.limo`;
|
2024-03-26 13:17:55 +01:00
|
|
|
|
|
|
|
|
if (navigator.clipboard) {
|
|
|
|
|
navigator.clipboard.writeText(shareLink);
|
|
|
|
|
} else {
|
|
|
|
|
alert('Your browser does not support clipboard API');
|
|
|
|
|
}
|
|
|
|
|
};
|