Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query strings on WSL #171

Merged
merged 3 commits into from Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions index.js
Expand Up @@ -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') {
Expand Down
12 changes: 10 additions & 2 deletions test.js
Expand Up @@ -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});
});
}