diff --git a/src/NetscriptWorker.ts b/src/NetscriptWorker.ts index cf9189db7..0b2e49ab8 100644 --- a/src/NetscriptWorker.ts +++ b/src/NetscriptWorker.ts @@ -421,9 +421,6 @@ export function runScriptFromScript( return 0; } - //prevent leading / from causing a bug - if (scriptname.startsWith("/")) scriptname = scriptname.slice(1); - if (typeof scriptname !== "string" || !Array.isArray(args)) { workerScript.log(caller, () => `Invalid arguments: scriptname='${scriptname} args='${args}'`); console.error(`runScriptFromScript() failed due to invalid arguments`); diff --git a/src/Server/BaseServer.ts b/src/Server/BaseServer.ts index 7cdbc6250..0a4434f00 100644 --- a/src/Server/BaseServer.ts +++ b/src/Server/BaseServer.ts @@ -129,7 +129,12 @@ export abstract class BaseServer { */ getRunningScript(scriptName: string, scriptArgs: ScriptArg[]): RunningScript | null { for (const rs of this.runningScripts) { - if (rs.filename === scriptName && compareArrays(rs.args, scriptArgs)) { + //compare file names without leading '/' to prevent running multiple script with the same name + if ( + (rs.filename.charAt(0) == "/" ? rs.filename.slice(1) : rs.filename) === + (scriptName.charAt(0) == "/" ? scriptName.slice(1) : scriptName) && + compareArrays(rs.args, scriptArgs) + ) { return rs; } }