Commit d512497f authored by arusakov's avatar arusakov Committed by Wandenberg

pushstream.js Utils.isCrossDomainUrl bugfix for IE

Signed-off-by: 's avatarWandenberg <wandenberg@gmail.com>
parent 1228624a
...@@ -422,9 +422,10 @@ Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider ...@@ -422,9 +422,10 @@ Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider
var getSubscriberUrl = function(pushstream, prefix, extraParams, withBacktrack) { var getSubscriberUrl = function(pushstream, prefix, extraParams, withBacktrack) {
var websocket = pushstream.wrapper.type === WebSocketWrapper.TYPE; var websocket = pushstream.wrapper.type === WebSocketWrapper.TYPE;
var useSSL = pushstream.useSSL; var useSSL = pushstream.useSSL;
var port = normalizePort(useSSL, pushstream.port);
var url = (websocket) ? ((useSSL) ? "wss://" : "ws://") : ((useSSL) ? "https://" : "http://"); var url = (websocket) ? ((useSSL) ? "wss://" : "ws://") : ((useSSL) ? "https://" : "http://");
url += pushstream.host; url += pushstream.host;
url += ((!useSSL && pushstream.port === 80) || (useSSL && pushstream.port === 443)) ? "" : (":" + pushstream.port); url += (port ? (":" + port) : "");
url += prefix; url += prefix;
var channels = getChannelsPath(pushstream.channels, withBacktrack); var channels = getChannelsPath(pushstream.channels, withBacktrack);
...@@ -439,10 +440,10 @@ Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider ...@@ -439,10 +440,10 @@ Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider
}; };
var getPublisherUrl = function(pushstream) { var getPublisherUrl = function(pushstream) {
var channel = ""; var port = normalizePort(pushstream.useSSL, pushstream.port);
var url = (pushstream.useSSL) ? "https://" : "http://"; var url = (pushstream.useSSL) ? "https://" : "http://";
url += pushstream.host; url += pushstream.host;
url += ((pushstream.port !== 80) && (pushstream.port !== 443)) ? (":" + pushstream.port) : ""; url += (port ? (":" + port) : "");
url += pushstream.urlPrefixPublisher; url += pushstream.urlPrefixPublisher;
url += "?id=" + getChannelsPath(pushstream.channels, false); url += "?id=" + getChannelsPath(pushstream.channels, false);
...@@ -463,6 +464,11 @@ Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider ...@@ -463,6 +464,11 @@ Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider
return domainParts.slice(-1 * keepNumber).join('.'); return domainParts.slice(-1 * keepNumber).join('.');
}; };
var normalizePort = function (useSSL, port) {
port = Number(port || (useSSL ? 443 : 80));
return ((!useSSL && port === 80) || (useSSL && port === 443)) ? "" : port;
};
Utils.isCrossDomainUrl = function(url) { Utils.isCrossDomainUrl = function(url) {
if (!url) { if (!url) {
return false; return false;
...@@ -471,9 +477,12 @@ Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider ...@@ -471,9 +477,12 @@ Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider
var parser = document.createElement('a'); var parser = document.createElement('a');
parser.href = url; parser.href = url;
var srcPort = normalizePort(window.location.protocol === "https:", window.location.port);
var dstPort = normalizePort(parser.protocol === "https:", parser.port);
return (window.location.protocol !== parser.protocol) || return (window.location.protocol !== parser.protocol) ||
(window.location.hostname !== parser.hostname) || (window.location.hostname !== parser.hostname) ||
(window.location.port !== parser.port); (srcPort !== dstPort);
}; };
var linker = function(method, instance) { var linker = function(method, instance) {
...@@ -748,8 +757,7 @@ Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider ...@@ -748,8 +757,7 @@ Authors: Wandenberg Peixoto <wandenberg@gmail.com>, Rogério Carvalho Schneider
this.urlWithBacktrack = getSubscriberUrl(this.pushstream, this.pushstream.urlPrefixLongpolling, {}, true); this.urlWithBacktrack = getSubscriberUrl(this.pushstream, this.pushstream.urlPrefixLongpolling, {}, true);
this.urlWithoutBacktrack = getSubscriberUrl(this.pushstream, this.pushstream.urlPrefixLongpolling, {}, false); this.urlWithoutBacktrack = getSubscriberUrl(this.pushstream, this.pushstream.urlPrefixLongpolling, {}, false);
this.xhrSettings.url = this.urlWithBacktrack; this.xhrSettings.url = this.urlWithBacktrack;
this.xhrSettings.crossDomain = Utils.isCrossDomainUrl(this.urlWithBacktrack); this.useJSONP = this.pushstream._crossDomain || this.pushstream.useJSONP;
this.useJSONP = this.xhrSettings.crossDomain || this.pushstream.useJSONP;
this.xhrSettings.scriptId = "PushStreamManager_" + this.pushstream.id; this.xhrSettings.scriptId = "PushStreamManager_" + this.pushstream.id;
if (this.useJSONP) { if (this.useJSONP) {
this.pushstream.messagesControlByArgument = true; this.pushstream.messagesControlByArgument = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment