1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | exports.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 |
|
21 | function getHost(baseUrl) {
|
22 | return (baseUrl.match(/\/\/([^/:]+)/) || [])[1] || 'localhost';
|
23 | }
|
24 |
|
25 | function getProtocol(baseUrl) {
|
26 | return (/https:/.test(baseUrl) ? 'https:' : 'http:'
|
27 | );
|
28 | }
|
29 |
|
30 | function 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 | }
|
38 | module.exports = exports['default']; |
\ | No newline at end of file |