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

Incorrect GM_openInTab behavior with relative paths #1719

Closed
nstepien opened this issue Mar 3, 2013 · 4 comments
Closed

Incorrect GM_openInTab behavior with relative paths #1719

nstepien opened this issue Mar 3, 2013 · 4 comments
Milestone

Comments

@nstepien
Copy link

nstepien commented Mar 3, 2013

/* FAIL: */
// opens https://path.com/ (WTF)
GM_openInTab('path');
// opens file:///path
GM_openInTab('/path');
// opens file:////domain.org
GM_openInTab('//domain.org');

/* WORK: */
// opens current protocol + current domain + current path + 'path'
window.open('path', '_blank');
// opens current protocol + current domain + '/path'
window.open('/path', '_blank');
// opens current protocol + 'domain.org'
window.open('//domain.org', '_blank');

I fixed that in my script by basically doing the following, which I really shouldn't have to:

open = function(URL) {
  var a = document.createElement('a');
  a.href = URL;
  GM_openInTab(a.href);
};
@janekptacijarabaci
Copy link
Contributor

In other words:
RFC 2396
Point No. 5 (5.2)

@nstepien
Copy link
Author

Yay.

@arantius
Copy link
Collaborator

arantius commented Jun 7, 2013

This fix is now in 1.10beta1; let me know if it works for you:
https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/versions/?page=1#version-1.10beta1

@nstepien
Copy link
Author

nstepien commented Jun 7, 2013

Works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants