open-browser.vim icon indicating copy to clipboard operation
open-browser.vim copied to clipboard

Only part of a full URL is opened

Open jdhao opened this issue 6 years ago • 4 comments

Hi, this is a great plugin which works both on Windows and Mac. I have found that for some URL, only part of the URL is opened in the browser. For example, for URL http://rrc.cvc.uab.es/?ch=2&com=tasks#WordRecognition, when I use this plugin to open it in the browser, only http://rrc.cvc.uab.es/?ch=2 is opened.

jdhao avatar Jul 23 '19 02:07 jdhao

I couldn't reproduce this on macOS. If this problem still persists, please tell me

  • Vim version
  • OS (and it's version)
  • Minimal steps to reproduce

tyru avatar Mar 10 '20 04:03 tyru

@tyru This problem still persists. Version info:

  • Neovim: 0.5.0 (any version above 0.4.0 should reproduce)
  • OS: Windows 10 1803

Minimal step to reproduce:

  • Create file init.vim with the following minimal setting:
set runtimepath=C:\Users\Administrator\AppData\Local\nvim-data\plugged\open-browser.vim,$VIMRUNTIME
nmap ob <Plug>(openbrowser-smart-search)
  • Create a file test.md with the above URL. The content in test.md:
http://rrc.cvc.uab.es/?ch=2&com=tasks#WordRecognition
  • Open test.md with the following command:
nvim -u init.vim test.md
  • Move the cursor to the URL and press ob.

Result: only http://rrc.cvc.uab.es/?ch=2 is opened in the browser.

BTW: my default browser is Chrome. I am not sure if this is relevant.

jdhao avatar Mar 10 '20 05:03 jdhao

It seems that it is a problem with Windows system, not related to this plugin. If we run the following following command directly from the command line:

chrome.exe http://rrc.cvc.uab.es/?ch=2&com=tasks#WordRecognition

The same issue occurs. According to here, & has special meanings on Windows. We have to quote the whole URL or use ^ to escape special characters. Both the following two commands works:

chrome.exe "http://rrc.cvc.uab.es/?ch=2&com=tasks#WordRecognition"
chrome.exe http://rrc.cvc.uab.es/?ch=2^&com=tasks#WordRecognition

jdhao avatar Mar 10 '20 05:03 jdhao

Thanks for the info. I'll look into this.

tyru avatar Mar 10 '20 17:03 tyru