Check if imageServers exists before cleaning eval/exec output

This commit is contained in:
Essem 2022-01-08 13:06:35 -06:00 committed by GitHub
parent 6475c91fbc
commit 671ddd8bbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,10 +26,12 @@ export async function clean(text) {
const { parsed } = config();
const imageServers = JSON.parse(fs.readFileSync("./servers.json", { encoding: "utf8" })).image;
if (imageServers && imageServers.length !== 0) {
for (const { server, auth } of imageServers) {
text = text.replaceAll(server, optionalReplace(server));
text = text.replaceAll(auth, optionalReplace(auth));
}
}
for (const env of Object.keys(parsed)) {
text = text.replaceAll(parsed[env], optionalReplace(parsed[env]));