From d8a508be1b23c80b53d0089b6f1e487e84f53a19 Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Wed, 29 Jan 2020 15:25:19 +0100 Subject: [PATCH] Fix URLs in WSL (#166) --- index.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index daa32b7..34d2ea9 100644 --- a/index.js +++ b/index.js @@ -65,16 +65,18 @@ module.exports = async (target, options) => { command = 'cmd' + (isWsl ? '.exe' : ''); cliArguments.push('/s', '/c', 'start', '""', '/b'); - // Always quoting target allows for URLs/paths to have spaces and unmarked characters, as `cmd.exe` will - // interpret them as plain text to be forwarded as one unique argument. Enabling `windowsVerbatimArguments` - // disables Node.js's default quotes and escapes handling (https://git.io/fjdem). - // References: - // - Issues #17, #44, #55, #77, #101, #115 - // - Pull requests: #74, #98 - // - // As a result, all double-quotes are stripped from the `target` and do not get to your desired destination. - target = `"${target}"`; - childProcessOptions.windowsVerbatimArguments = true; + if (!isWsl) { + // Always quoting target allows for URLs/paths to have spaces and unmarked characters, as `cmd.exe` will + // interpret them as plain text to be forwarded as one unique argument. Enabling `windowsVerbatimArguments` + // disables Node.js's default quotes and escapes handling (https://git.io/fjdem). + // References: + // - Issues #17, #44, #55, #77, #101, #115 + // - Pull requests: #74, #98 + // + // As a result, all double-quotes are stripped from the `target` and do not get to your desired destination. + target = `"${target}"`; + childProcessOptions.windowsVerbatimArguments = true; + } if (options.wait) { cliArguments.push('/wait');