OLD | NEW |
1 function get_host_info() { | 1 function get_host_info() { |
2 | 2 |
3 var HTTP_PORT = '{{ports[http][0]}}'; | 3 var HTTP_PORT = '{{ports[http][0]}}'; |
4 var HTTP_PORT2 = '{{ports[http][1]}}'; | 4 var HTTP_PORT2 = '{{ports[http][1]}}'; |
5 var HTTPS_PORT = '{{ports[https][0]}}'; | 5 var HTTPS_PORT = '{{ports[https][0]}}'; |
6 var ORIGINAL_HOST = '{{host}}'; | 6 var ORIGINAL_HOST = '{{host}}'; |
7 var REMOTE_HOST = (ORIGINAL_HOST === 'localhost') ? '127.0.0.1' : ('www1.' + O
RIGINAL_HOST); | 7 var REMOTE_HOST = (ORIGINAL_HOST === 'localhost') ? '127.0.0.1' : ('www1.' + O
RIGINAL_HOST); |
| 8 var OTHER_HOST = '{{domains[www2]}}'; |
8 | 9 |
9 return { | 10 return { |
10 HTTP_PORT: HTTP_PORT, | 11 HTTP_PORT: HTTP_PORT, |
11 HTTP_PORT2: HTTP_PORT2, | 12 HTTP_PORT2: HTTP_PORT2, |
12 HTTPS_PORT: HTTPS_PORT, | 13 HTTPS_PORT: HTTPS_PORT, |
13 ORIGINAL_HOST: ORIGINAL_HOST, | 14 ORIGINAL_HOST: ORIGINAL_HOST, |
14 REMOTE_HOST: REMOTE_HOST, | 15 REMOTE_HOST: REMOTE_HOST, |
15 | 16 |
16 HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT, | 17 HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT, |
17 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT, | 18 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT, |
18 HTTPS_ORIGIN_WITH_CREDS: 'https://foo:bar@' + ORIGINAL_HOST + ':' + HTTPS_PO
RT, | 19 HTTPS_ORIGIN_WITH_CREDS: 'https://foo:bar@' + ORIGINAL_HOST + ':' + HTTPS_PO
RT, |
19 HTTP_ORIGIN_WITH_DIFFERENT_PORT: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT
2, | 20 HTTP_ORIGIN_WITH_DIFFERENT_PORT: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT
2, |
20 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT, | 21 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT, |
21 HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT: 'http://' + REMOTE_HOST + ':' + HTTP
_PORT2, | 22 HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT: 'http://' + REMOTE_HOST + ':' + HTTP
_PORT2, |
22 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT, | 23 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT, |
23 HTTPS_REMOTE_ORIGIN_WITH_CREDS: 'https://foo:bar@' + REMOTE_HOST + ':' + HTT
PS_PORT, | 24 HTTPS_REMOTE_ORIGIN_WITH_CREDS: 'https://foo:bar@' + REMOTE_HOST + ':' + HTT
PS_PORT, |
| 25 UNAUTHENTICATED_ORIGIN: 'http://' + OTHER_HOST + ':' + HTTP_PORT, |
| 26 AUTHENTICATED_ORIGIN: 'https://' + OTHER_HOST + ':' + HTTPS_PORT |
24 }; | 27 }; |
25 } | 28 } |
26 | 29 |
27 function get_port(loc) { | 30 function get_port(loc) { |
28 // When a default port is used, location.port returns the empty string. | 31 // When a default port is used, location.port returns the empty string. |
29 // To compare with wptserve `ports` substitution we need a port... | 32 // To compare with wptserve `ports` substitution we need a port... |
30 // loc can be Location/<a>/<area>/URL, but assumes http/https only. | 33 // loc can be Location/<a>/<area>/URL, but assumes http/https only. |
31 if (loc.port) { | 34 if (loc.port) { |
32 return loc.port; | 35 return loc.port; |
33 } | 36 } |
34 return loc.protocol === 'https:' ? '443' : '80'; | 37 return loc.protocol === 'https:' ? '443' : '80'; |
35 } | 38 } |
OLD | NEW |