diff --git a/index.js b/index.js index 5fe49ad..0f55ada 100644 --- a/index.js +++ b/index.js @@ -46,6 +46,10 @@ module.exports = async (target, options) => { // can be used on any platform. if (options.url) { target = encodeURI(target); + + if (isWsl) { + target = target.replace(/&/g, '^&'); + } } if (process.platform === 'darwin') { diff --git a/test.js b/test.js index 550a204..91af5d5 100644 --- a/test.js +++ b/test.js @@ -79,11 +79,19 @@ test('open URL with query strings, spaces, pipes and a fragment', async () => { }); if (isWsl) { - test('open URL in specified windows app given a wsl path to the app', async () => { + test('open URL in specified Windows app given a WSL path to the app', async () => { await open('https://sindresorhus.com', {app: firefoxWslName}); }); - test('open URL in specified windows app with arguments given a wsl path to the app', async () => { + test('open URL in specified Windows app with arguments given a WSL path to the app', async () => { await open('https://sindresorhus.com', {app: [chromeWslName, '--incognito']}); }); + + test('open URL with query strings and spaces works with `url` option', async () => { + await open('https://sindresorhus.com/?abc=123&def=456&ghi=with spaces', {url: true}); + }); + + test('open URL with query strings works with `url` option', async () => { + await open('https://sindresorhus.com/?abc=123&def=456', {url: true}); + }); }