修复错误

This commit is contained in:
wood 2024-06-13 00:24:24 +08:00
parent af3de52fc9
commit d1eba7746d
2 changed files with 21 additions and 11 deletions

View File

View File

@ -115,7 +115,7 @@ function getHomePageHtml(): string {
function generateCommands() { function generateCommands() {
const imageInput = document.getElementById('imageInput').value; const imageInput = document.getElementById('imageInput').value;
const source = getSourceFromImage(imageInput); const source = getSourceFromImage(imageInput);
const imageName = getImageNameFromInput(imageInput); const imageName = getImageNameFromInput(imageInput, source);
const dockerPullCommand = \`docker pull \${source}/\${imageName}\`; const dockerPullCommand = \`docker pull \${source}/\${imageName}\`;
const dockerTagCommand = \`docker tag \${source}/\${imageName} \${imageName}\`; const dockerTagCommand = \`docker tag \${source}/\${imageName} \${imageName}\`;
const dockerRmiCommand = \`docker rmi \${source}/\${imageName}\`; const dockerRmiCommand = \`docker rmi \${source}/\${imageName}\`;
@ -140,8 +140,18 @@ function getHomePageHtml(): string {
} }
} }
function getImageNameFromInput(imageInput) { function getImageNameFromInput(imageInput, source) {
return imageInput.replace(/^.+?\\//, ''); if (imageInput.startsWith("gcr.io/")) {
return imageInput.replace("gcr.io/", "");
} else if (imageInput.startsWith("k8s.gcr.io/")) {
return imageInput.replace("k8s.gcr.io/", "");
} else if (imageInput.startsWith("quay.io/")) {
return imageInput.replace("quay.io/", "");
} else if (imageInput.startsWith("ghcr.io/")) {
return imageInput.replace("ghcr.io/", "");
} else {
return imageInput;
}
} }
function copyToClipboard(elementId) { function copyToClipboard(elementId) {