2025-06-03 22:11:17 +02:00
|
|
|
import { copyToClipboard } from './clipboard-utils';
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-03 22:11:17 +02:00
|
|
|
export const copyShareLinkToClipboard = async (subplebbitAddress: string, cid: string) => {
|
|
|
|
|
const shareLink = `https://pleb.bz/p/${subplebbitAddress}/c/${cid}?redirect=plebchan.app`;
|
|
|
|
|
await copyToClipboard(shareLink);
|
2024-03-26 13:17:55 +01:00
|
|
|
};
|