Skip to content

Commit

Permalink
Support URLs using hashes. See #255
Browse files Browse the repository at this point in the history
  • Loading branch information
aarranz committed Nov 17, 2016
1 parent e5166f6 commit 3ef1857
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/wirecloud/platform/static/js/wirecloud/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Wirecloud.location = {
var io = {};

io.buildProxyURL = function buildProxyURL(url, options) {
var forceProxy, inmemoryurl;
var forceProxy, hash;

options = utils.merge({
method: 'POST',
Expand All @@ -233,17 +233,21 @@ Wirecloud.location = {
}

forceProxy = !!options.forceProxy;
inmemoryurl = ["blob:", "data:"].indexOf(url.protocol) !== -1;
if (["blob:", "data:"].indexOf(url.protocol) !== -1) {
return url.toString();
}

if (!inmemoryurl && (forceProxy || (options.supportsAccessControl !== true && url.origin !== Wirecloud.location.domain))) {
hash = url.hash;
url.hash = '';
if (forceProxy || (options.supportsAccessControl !== true && url.origin !== Wirecloud.location.domain)) {
url = Wirecloud.location.domain +
Wirecloud.URLs.PROXY.evaluate({protocol: url.protocol.slice(0, -1), domain: url.host, path: url.pathname}) + url.search;
} else {
url = url.toString();
}

// Add parameters
if (!inmemoryurl && options.parameters != null && (typeof options.parameters === 'string' || typeof options.parameters === 'object')) {
if (options.parameters != null && (typeof options.parameters === 'string' || typeof options.parameters === 'object')) {
if (['PUT', 'POST'].indexOf(options.method) === -1 || options.postBody != null) {
if (url.indexOf('?') !== -1) {
url += '&' + toQueryString(options.parameters);
Expand All @@ -253,7 +257,7 @@ Wirecloud.location = {
}
}

return url;
return url + hash;
};

io.makeRequest = function makeRequest(url, options) {
Expand Down

0 comments on commit 3ef1857

Please sign in to comment.