mirror of
https://github.com/plebbit/seedit.git
synced 2026-06-12 10:06:05 -04:00
27 lines
609 B
TypeScript
27 lines
609 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}?redirect=seedit.eth.limo`;
|
|
|
|
if (navigator.clipboard) {
|
|
navigator.clipboard.writeText(shareLink);
|
|
} else {
|
|
alert('Your browser does not support clipboard API');
|
|
}
|
|
};
|