refactor(Buttons): reorganize URL transformation function

This commit is contained in:
Bram Suurd
2024-10-26 12:39:37 +02:00
parent c9103638d4
commit 5b32cb6a80
@@ -11,6 +11,15 @@ export default function Buttons({ item }: { item: Script }) {
[],
);
const transformUrlToInstallScript = (url: string): string => {
if (url.includes("/pve/")) {
return url;
} else if (url.includes("/ct/")) {
return url.replace("/ct/", "/install/").replace(/\.sh$/, "-install.sh");
}
return url;
};
const sourceUrl = useMemo(() => {
if (item.installCommand) {
const match = item.installCommand.match(pattern);
@@ -19,15 +28,6 @@ export default function Buttons({ item }: { item: Script }) {
return null;
}, [item.installCommand, pattern]);
const transformUrlToInstallScript = (url: string): string => {
if (url.includes("/pve/")) {
return url;
} else if (url.includes("/ct/")) {
return url.replace("/ct/", "/install/").replace(/\.sh$/, "-install.sh");
}
return url;
};
return (
<div className="flex flex-wrap justify-end gap-2">
{item.website && (