Index: net/data/websocket/split_packet_check.html |
diff --git a/net/data/websocket/split_packet_check.html b/net/data/websocket/split_packet_check.html |
index 6b7e980a788a7533942a8ee991b2b06bcadc657d..a7f4c365f56d6f0026bbcd3d1966943715e282f6 100644 |
--- a/net/data/websocket/split_packet_check.html |
+++ b/net/data/websocket/split_packet_check.html |
@@ -3,8 +3,16 @@ |
<head> |
<title>test ws split packet</title> |
<script type="text/javascript"> |
-var protocol = location.protocol.replace('http', 'ws'); |
-var url = protocol + '//' + location.host + '/close-with-split-packet'; |
+ |
+var href = window.location.href; |
+var hostBegin = href.indexOf('/') + 2; |
+var hostEnd = href.lastIndexOf(':'); |
+var host = href.slice(hostBegin, hostEnd); |
+var portBegin = hostEnd + 1; |
+var portEnd = href.lastIndexOf('/'); |
+var port = href.slice(portBegin, portEnd); |
+var scheme = href.indexOf('https') >= 0 ? 'wss' : 'ws'; |
+var url = scheme + '://' + host + ':' + port + '/close-with-split-packet'; |
// Do connection test. |
var ws = new WebSocket(url); |