Fix a few other bugs

This commit is contained in:
Olivier Gagnon
2021-08-21 11:30:31 -04:00
parent 4de20f8cce
commit 4b8e63f342
3 changed files with 8 additions and 3 deletions
+5 -1
View File
@@ -2149,11 +2149,15 @@ function NetscriptFunctions(workerScript) {
}
return port.write(data);
} else if (isString(port)) { // Write to script or text file
const fn = removeLeadingSlash(port);
let fn = port;
if (!isValidFilePath(fn)) {
throw makeRuntimeErrorMsg("write", `Invalid filepath: ${fn}`);
}
if(fn.lastIndexOf("/") === 0) {
fn = removeLeadingSlash(fn);
}
// Coerce 'data' to be a string
try {
data = String(data);