Skip to content

Commit

Permalink
refactor: Transform source URL to install script URL in ScriptItem co…
Browse files Browse the repository at this point in the history
…mponent
  • Loading branch information
BramSuurdje committed Jun 8, 2024
1 parent 8939e93 commit 230841d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion components/Script.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,24 @@ function ScriptItem({
}, [item, pattern]);

const sourceUrl = useMemo(() => {
const transformUrlToInstallScript = (url: string) => {
if (url.includes("/misc/") || url.includes("/vm/")) {
return url;
} else if (url.includes("/ct/")) {
return url.replace("/ct/", "/install/").replace(/\.sh$/, "-install.sh");
}
return url;
};

if (installCommand) {
const match = installCommand.match(pattern);
return match ? match[0] : null;
return match ? transformUrlToInstallScript(match[0]) : null;
}
return null;
}, [installCommand, pattern]);



const handleCopy = (type: string, value: any) => {
navigator.clipboard.writeText(value);

Expand Down

0 comments on commit 230841d

Please sign in to comment.