From 163a4c0015b7a96765f8aaa9050c8f5d22c71538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?WR=CE=9BK=CE=9EN?= Date: Mon, 28 Nov 2022 17:56:32 +0100 Subject: [PATCH] Don't clean destination in getFile command As a linux user I need to keep a single slash in my `destination` and not a double backslash. With this change, `destination` arg of `getFile` function is not escaped. --- index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 38788de..e8ffd5f 100644 --- a/index.js +++ b/index.js @@ -11,8 +11,13 @@ const singleSlash = /\//g; const missingFileRegex = /(NT_STATUS_OBJECT_NAME_NOT_FOUND|NT_STATUS_NO_SUCH_FILE)/im; -const getCleanedSmbClientArgs = (args) => - args.map((arg) => `"${arg.replace(singleSlash, "\\")}"`).join(" "); +const getCleanedSmbClientArgs = (args) => { + if (Array.isArray(args)) { + return args.map((arg) => `"${arg.replace(singleSlash, "\\")}"`).join(" "); + } else { + return `"${args.replace(singleSlash, "\\")}"`; + } +} class SambaClient { constructor(options) { @@ -29,7 +34,7 @@ class SambaClient { } async getFile(path, destination, workingDir) { - return await this.execute("get", [path, destination], workingDir); + return await this.execute("get", `${getCleanedSmbClientArgs(path)} "${destination}"`, workingDir); } async sendFile(path, destination) {