ns.scp: strip leading slashes from filenames if file is in root (#263)

This commit is contained in:
lucebac 2023-02-28 12:53:42 +01:00 committed by GitHub
parent f1793b187b
commit ae92ea0f94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -828,7 +828,10 @@ export const ns: InternalAPI<NSFull> = {
let noFailures = true; let noFailures = true;
//ts detects files as any[] here even though we would have thrown in the above loop if it wasn't string[] //ts detects files as any[] here even though we would have thrown in the above loop if it wasn't string[]
for (const file of files as string[]) { for (let file of files as string[]) {
// cut off the leading / for files in the root of the server; this assumes that the filename is somewhat normalized and doesn't look like `//file.js`
if (file.startsWith("/") && file.indexOf("/", 1) === -1) file = file.slice(1);
// Scp for lit files // Scp for lit files
if (file.endsWith(".lit")) { if (file.endsWith(".lit")) {
const sourceMessage = sourceServ.messages.find((message) => message === file); const sourceMessage = sourceServ.messages.find((message) => message === file);