rauschma / openurl

Node.js module for opening a URL via the operating system
71 stars 19 forks source link

URLs with "=" do not open in Windows, opens explorer folder instead #2

Open prashantv opened 12 years ago

prashantv commented 12 years ago

When trying to use openurl to open a link with equals, eg, "http://www.google.com/test=a", openurl ends up opening an explorer window instead of the browser.

I found a alternate way to open URLs with special characters in Windows that you may want to use instead:

  var exec = require("child_process").exec
  execStr = "explorer.exe ^\"" + url + "^\"";
  exec(execStr);
rauschma commented 12 years ago

Can you explain what is going on? Interesting that one needs the hat (^), twice.

That looks like a Node.js bug, you might want to report it (e.g. by posting to the appropriate Node.js Google Group).

prashantv commented 12 years ago

Yeah I wasn't sure if it was a Node.js bug or not, but the ^ character is the escape character for cmd. So by using exec, I know that it'll call cmd directly, and I can escape the URL directly. It runs the command passed to it in double quotes, so something like: cmd /c /s "[command]"

I want to pass it explorer.exe "url", but since the original command already has double quotes, I want to escape the double quotes, hence the ^.

I took a look at the node.js code to see if there was a bug, but couldn't really tell, do you think that the current way should definitely work?

jmc-88 commented 11 years ago

I've just submitted a pull request that uses the "start" command (built inside cmd.exe) to launch the default browser, and should also fix this issue. I've tested it on the URL indicated by prashantv and it seems to work correctly.

sp00x commented 9 years ago

This was never fixed? Ran into it today when trying to use this module..

jmc-88 commented 9 years ago

No, I think this was never fixed. The pull request (https://github.com/rauschma/openurl/pull/3) I filed almost three years ago has never received any reply.

kaelzhang commented 8 years ago

@jmc-88 cmd -c start is the very better way

BrianGenisio commented 8 years ago

Can you merge and publish PR (https://github.com/rauschma/openurl/pull/3)? If you'd rather not maintain this anymore, can you transfer this to someone who will? (I'd be happy to)

Interagierende-Systeme commented 7 years ago

Hi everyone, if anyone is still facing this problem, we published a fork to solve this problem as well: https://github.com/Interagierende-Systeme/openurl2