summaryrefslogtreecommitdiffstats
path: root/web/gui/src/dashboard.js/server-detection.js
blob: 472ad48be7e7c2a14e0b5d267e6f13c584867325 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// *** src/dashboard.js/server-detection.js

if (typeof netdataServer !== 'undefined') {
    NETDATA.serverDefault = netdataServer;
} else {
    let s = NETDATA._scriptSource();
    if (s) {
        NETDATA.serverDefault = s.replace(/\/dashboard.js(\?.*)?$/g, "");
    } else {
        console.log('WARNING: Cannot detect the URL of the netdata server.');
        NETDATA.serverDefault = null;
    }
}

if (NETDATA.serverDefault === null) {
    NETDATA.serverDefault = '';
} else if (NETDATA.serverDefault.slice(-1) !== '/') {
    NETDATA.serverDefault += '/';
}

if (typeof netdataServerStatic !== 'undefined' && netdataServerStatic !== null && netdataServerStatic !== '') {
    NETDATA.serverStatic = netdataServerStatic;
    if (NETDATA.serverStatic.slice(-1) !== '/') {
        NETDATA.serverStatic += '/';
    }
} else {
    NETDATA.serverStatic = NETDATA.serverDefault;
}