mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
27 lines
584 B
TypeScript
27 lines
584 B
TypeScript
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');
|
|
}
|
|
};
|