sindresorhus/opn

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Windows paths with forward-slashes don't work as of v7.2.0 #216

abythell posted onGitHub

#188 introduced Powershell and a new method for encoding arguments. By wrapping the target in, "double quote with double quotes to ensure the inner quotes are passed through", paths with forward slashes on Windows no longer get reinterpreted as they did before, causing open to fail.

I believe this to also be the cause of sindresorhus/open-cli#16 as open-cli@6.0.1 works on Windows with a target path like dist\report.html but not with dist/report.html, unlike earlier versions which worked with both.

Currently, target has slashes and backticks added to it before encoding:

// target = 'dist/report.html'
encodedArguments.push(`"\`"${target}\`""`); // result: "`"dist/report.html`""

... which doesn't actually result in the file being opened. If instead the target is passed as-is:

// target = 'dist/report.html'
encodedArguments.push(target); // result: dist/report.html

...then open works as expected.

Of course, this isn't a proper solution, because I'm sure those quotes and ticks are being inserted for a purpose, but this hopefully demonstrates the issue for someone else with a better understanding of Powershell.


Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests