Skip to content

Commit 1a44e07

Browse files
authored
Merge pull request #52 from julianz/patch-1
Handle non-standard ports in wstest.html
2 parents 42d1bde + 6d386e7 commit 1a44e07

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

www/wstest.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,20 @@
2020

2121
function testWebSocket()
2222
{
23-
var scheme
23+
var scheme, defaultPort
2424
if (window.location.protocol == 'https:')
25+
{
2526
scheme = 'wss:';
27+
defaultPort = 443;
28+
}
2629
else
30+
{
2731
scheme = 'ws:';
32+
defaultPort = 80;
33+
}
2834
var wsUri = scheme + '//' + window.location.hostname;
35+
if (window.location.port !== defaultPort)
36+
wsUri += ':' + window.location.port;
2937
writeToScreen("Connecting to " + wsUri + "...")
3038
websocket = new WebSocket(wsUri);
3139
websocket.onopen = function(evt) { onOpen (evt) };
@@ -81,4 +89,4 @@ <h1>MicroWebSrv2 - WebSockets Module</h1>
8189
<div id="output"></div>
8290
</body>
8391

84-
</html>
92+
</html>

0 commit comments

Comments
 (0)