Skip to content

Commit

Permalink
URL is now filled automatically if RESTClient APS is opened from POA …
Browse files Browse the repository at this point in the history
…tab.
  • Loading branch information
gear54rus committed Apr 13, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 939d26a commit 84c8bd0
Showing 3 changed files with 32 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/content/js/restclient.helper.js
Original file line number Diff line number Diff line change
@@ -155,6 +155,32 @@ restclient.helper = {

return parts.protocol + parts.doubleSlash + parts.authority + parts.pathname + search;
},
getQuery: function(href) {
var param = typeof href === 'string';
do {
var tmp = (param ? href : decodeURI(window.location.search)),
tmp1,
result = {};
if (!tmp.length)
break;
tmp = tmp.split('?');
if (tmp.length === 1)
break;
tmp = tmp[tmp.length - 1];
if (!tmp.length)
break;
tmp.split('&').forEach(function(v) {
tmp = v.indexOf('=');
if (tmp === 0)
return;
if (tmp === -1)
result[v] = '';
else
result[v.slice(0, tmp)] = v.slice(tmp + 1);
});
} while (false);
return result;
},
validateUrl: function (url) {
return this.isAbsoluteUrl(url);
},
5 changes: 5 additions & 0 deletions src/content/js/restclient.main.js
Original file line number Diff line number Diff line change
@@ -495,6 +495,11 @@ restclient.main = {
$('#request-url').val($(this).data('url'));
restclient.main.updateFavoriteUrlIcon();
});
var queryObject = restclient.helper.getQuery();
if (queryObject.url) {
$('#request-url').val(queryObject.url + 'aps/2/resources/');
history.pushState({}, '', location.origin + location.pathname + location.hash);
}
},
getCachedUrls: function () {
if (restclient.main.cachedUrls)
2 changes: 1 addition & 1 deletion src/content/js/restclient.overlay.js
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ restclient.overlay = {
},
open: function(){
var browser = restclient.overlay.getBrowser();
browser.selectedTab = browser.addTab("chrome://restclient/content/restclient.html");
browser.selectedTab = browser.addTab('chrome://restclient/content/restclient.html' + (browser.contentDocument.querySelector('script[src^="/pem/common/js/pem.js"]') ? '?url=' + browser.currentURI.specIgnoringRef : ''));
}
}
window.addEventListener("load", function(){ restclient.overlay.init(); }, false);

0 comments on commit 84c8bd0

Please # to comment.