Incorrect GM_openInTab behavior with relative paths #1719

Closed
MayhemYDG opened this Issue Mar 3, 2013 · 4 comments

Projects

None yet

3 participants

@MayhemYDG
/* 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);
};
Contributor

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

@arantius arantius closed this in c3d80bf May 23, 2013

Yay.

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

Works for me.

@kuehlschrank kuehlschrank referenced this issue in scriptish/scriptish Jul 21, 2013
Closed

Handle relative URLs in GM_openInTab #139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment