소스 검색

Detect port properly in vnc_auto.html when used on port 80 or 443.

Browsers (such as Chrome) don't report port numbers in window.location.port when
used on standard ports such as 80 and 443. This causes vnc_auto.html to not
automatically find the port as it should.

This simple change checks if window.location.port is blank, and sets port as
appropriate from the name of the protocol in use.
Will Rouesnel 12 년 전
부모
커밋
e83b9e03eb
1개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  1. 11 0
      vnc_auto.html

+ 11 - 0
vnc_auto.html

@@ -122,6 +122,17 @@
             host = WebUtil.getQueryVar('host', window.location.hostname);
             host = WebUtil.getQueryVar('host', window.location.hostname);
             port = WebUtil.getQueryVar('port', window.location.port);
             port = WebUtil.getQueryVar('port', window.location.port);
 
 
+            // if port == 80 (or 443) then it won't be present and should be
+            // set manually
+            if (!port) {
+                if (window.location.protocol.substring(0,4) == 'http') {            
+                    port = 80;
+                }
+                else if (window.location.protocol.substring(0,5) == 'https') {            
+                    port = 443;
+                }
+            }
+
             // If a token variable is passed in, set the parameter in a cookie.
             // If a token variable is passed in, set the parameter in a cookie.
             // This is used by nova-novncproxy.
             // This is used by nova-novncproxy.
             token = WebUtil.getQueryVar('token', null);
             token = WebUtil.getQueryVar('token', null);