UNPKG

858 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7exports.default = function (baseUrl) {
8 window.__racerHighwayClientOptions = {
9 base: '/channel',
10 reconnect: true,
11 browserChannelOnly: false,
12 srvProtocol: getProtocol(baseUrl),
13 srvHost: getHost(baseUrl),
14 srvPort: getPort(baseUrl),
15 srvSecurePort: getPort(baseUrl),
16 timeout: 10000,
17 timeoutIncrement: 10000
18 };
19};
20
21function getHost(baseUrl) {
22 return (baseUrl.match(/\/\/([^/:]+)/) || [])[1] || 'localhost';
23}
24
25function getProtocol(baseUrl) {
26 return (/https:/.test(baseUrl) ? 'https:' : 'http:'
27 );
28}
29
30function getPort(baseUrl) {
31 var port = ~~(baseUrl.match(/:(\d+)/) || [])[1];
32 if (!port) {
33 var protocol = getProtocol(baseUrl);
34 port = protocol === 'https:' ? 443 : 80;
35 }
36 return port;
37}
38module.exports = exports['default'];
\No newline at end of file