Skip to content

Commit 1e716b8

Browse files
tiagonapolisindresorhus
andauthoredMar 9, 2020
Fix query strings on WSL (#171)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1 parent 30f4abe commit 1e716b8

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed
 

‎index.js

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ module.exports = async (target, options) => {
4646
// can be used on any platform.
4747
if (options.url) {
4848
target = encodeURI(target);
49+
50+
if (isWsl) {
51+
target = target.replace(/&/g, '^&');
52+
}
4953
}
5054

5155
if (process.platform === 'darwin') {

‎test.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,19 @@ test('open URL with query strings, spaces, pipes and a fragment', async () => {
7979
});
8080

8181
if (isWsl) {
82-
test('open URL in specified windows app given a wsl path to the app', async () => {
82+
test('open URL in specified Windows app given a WSL path to the app', async () => {
8383
await open('https://sindresorhus.com', {app: firefoxWslName});
8484
});
8585

86-
test('open URL in specified windows app with arguments given a wsl path to the app', async () => {
86+
test('open URL in specified Windows app with arguments given a WSL path to the app', async () => {
8787
await open('https://sindresorhus.com', {app: [chromeWslName, '--incognito']});
8888
});
89+
90+
test('open URL with query strings and spaces works with `url` option', async () => {
91+
await open('https://sindresorhus.com/?abc=123&def=456&ghi=with spaces', {url: true});
92+
});
93+
94+
test('open URL with query strings works with `url` option', async () => {
95+
await open('https://sindresorhus.com/?abc=123&def=456', {url: true});
96+
});
8997
}

0 commit comments

Comments
 (0)
Please sign in to comment.