Permalink
Browse files

Use specified url instead of document url when the document protocol …

…isn't http or https.


Fixes #407
  • Loading branch information...
davidfowl committed May 21, 2012
1 parent 2bd4935 commit af30333f670e2d8763228d8db0aa3bf93135fad0
@@ -483,9 +483,18 @@
}
else {
// Determine the protocol
- protocol = document.location.protocol === "https:" ? "wss://" : "ws://";
+ var info = document.location;
+ if (info.protocol !== "http:" && info.protocol !== "https:") {
+ // If the url isn't isn't http or https, use the specified url instead of
+ // the document url.
+ // REVIEW: We need to make sure connection.url is absolute
+ var info = document.createElement('a');
+ info.href = connection.url;
+ }
+
+ protocol = info.protocol === "https:" ? "wss://" : "ws://";
- url = protocol + document.location.host + connection.appRelativeUrl;
+ url = protocol + info.host + connection.appRelativeUrl;
}
// Build the url

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -483,9 +483,18 @@
}
else {
// Determine the protocol
- protocol = document.location.protocol === "https:" ? "wss://" : "ws://";
+ var info = document.location;
+ if (info.protocol !== "http:" && info.protocol !== "https:") {
+ // If the url isn't isn't http or https, use the specified url instead of
+ // the document url.
+ // REVIEW: We need to make sure connection.url is absolute
+ var info = document.createElement('a');
+ info.href = connection.url;
+ }
+
+ protocol = info.protocol === "https:" ? "wss://" : "ws://";
- url = protocol + document.location.host + connection.appRelativeUrl;
+ url = protocol + info.host + connection.appRelativeUrl;
}
// Build the url

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -483,9 +483,18 @@
}
else {
// Determine the protocol
- protocol = document.location.protocol === "https:" ? "wss://" : "ws://";
+ var info = document.location;
+ if (info.protocol !== "http:" && info.protocol !== "https:") {
+ // If the url isn't isn't http or https, use the specified url instead of
+ // the document url.
+ // REVIEW: We need to make sure connection.url is absolute
+ var info = document.createElement('a');
+ info.href = connection.url;
+ }
+
+ protocol = info.protocol === "https:" ? "wss://" : "ws://";
- url = protocol + document.location.host + connection.appRelativeUrl;
+ url = protocol + info.host + connection.appRelativeUrl;
}
// Build the url

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -483,9 +483,18 @@
}
else {
// Determine the protocol
- protocol = document.location.protocol === "https:" ? "wss://" : "ws://";
+ var info = document.location;
+ if (info.protocol !== "http:" && info.protocol !== "https:") {
+ // If the url isn't isn't http or https, use the specified url instead of
+ // the document url.
+ // REVIEW: We need to make sure connection.url is absolute
+ var info = document.createElement('a');
+ info.href = connection.url;
+ }
+
+ protocol = info.protocol === "https:" ? "wss://" : "ws://";
- url = protocol + document.location.host + connection.appRelativeUrl;
+ url = protocol + info.host + connection.appRelativeUrl;
}
// Build the url

Large diffs are not rendered by default.

Oops, something went wrong.

0 comments on commit af30333

Please sign in to comment.