refactor: Transform source URL to install script URL in ScriptItem component
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user