node-red-contrib-unifi-ultimate 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/nodes/unifi-access-config.html +18 -0
- package/nodes/unifi-access-config.js +3 -1
- package/nodes/unifi-network-config.html +18 -0
- package/nodes/unifi-network-config.js +11 -5
- package/nodes/unifi-protect-config.html +18 -0
- package/nodes/unifi-protect-config.js +3 -1
- package/nodes/utils/common-utils.js +53 -0
- package/nodes/utils/unifi-access-utils.js +11 -4
- package/nodes/utils/unifi-network-utils.js +5 -2
- package/nodes/utils/unifi-protect-utils.js +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,8 @@ In Node-RED:
|
|
|
52
52
|
> **Tip:** For most actions, the incoming message is just a trigger — the node uses the device and action you configured in the editor.
|
|
53
53
|
> The only exception is **Control POE** with the *POE controlled by incoming message* action: send `true` to turn PoE on and `false` to turn it off.
|
|
54
54
|
|
|
55
|
+
> **Custom port:** Each config node has an optional **Port** field. Leave it empty to use the default (`443` for Network/Protect, `12445` for Access). Set it when your controller listens on a custom port — for example a **UniFi OS server** that uses `11443`. A port written directly in the controller address (`host:port`) takes precedence over this field.
|
|
56
|
+
|
|
55
57
|
<br/>
|
|
56
58
|
<br/>
|
|
57
59
|
<p align="left">
|
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
defaults: {
|
|
7
7
|
name: { value: "Unifi Access Config" },
|
|
8
8
|
host: { value: "", required: true },
|
|
9
|
+
port: {
|
|
10
|
+
value: "",
|
|
11
|
+
required: false,
|
|
12
|
+
validate: function (value) {
|
|
13
|
+
if (value === undefined || value === null || value === "") {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return /^\d+$/.test(String(value)) && Number(value) >= 1 && Number(value) <= 65535;
|
|
17
|
+
}
|
|
18
|
+
},
|
|
9
19
|
rejectUnauthorized: { value: false }
|
|
10
20
|
},
|
|
11
21
|
credentials: {
|
|
@@ -17,14 +27,17 @@
|
|
|
17
27
|
oneditprepare: function () {
|
|
18
28
|
const node = this;
|
|
19
29
|
const $hostInput = $("#node-config-input-host");
|
|
30
|
+
const $port = $("#node-config-input-port");
|
|
20
31
|
const $apiToken = $("#node-config-input-apiToken");
|
|
21
32
|
const $rejectUnauthorized = $("#node-config-input-rejectUnauthorized");
|
|
33
|
+
const $portRow = $port.closest(".form-row");
|
|
22
34
|
const $apiTokenRow = $apiToken.closest(".form-row");
|
|
23
35
|
const $securityRow = $rejectUnauthorized.closest(".form-row");
|
|
24
36
|
const $advancedRow = $("#node-config-row-advanced");
|
|
25
37
|
|
|
26
38
|
function syncProgressiveRows() {
|
|
27
39
|
const hasHost = String($hostInput.val() || node.host || "").trim() !== "";
|
|
40
|
+
$portRow.toggle(hasHost);
|
|
28
41
|
$apiTokenRow.toggle(hasHost);
|
|
29
42
|
$securityRow.toggle(hasHost);
|
|
30
43
|
$advancedRow.toggle(hasHost);
|
|
@@ -60,6 +73,10 @@
|
|
|
60
73
|
<label for="node-config-input-host"><i class="fa fa-globe"></i> Controller</label>
|
|
61
74
|
<input type="text" id="node-config-input-host" placeholder="192.168.1.10 or access.local:12445">
|
|
62
75
|
</div>
|
|
76
|
+
<div class="form-row">
|
|
77
|
+
<label for="node-config-input-port"><i class="fa fa-plug"></i> Port</label>
|
|
78
|
+
<input type="text" id="node-config-input-port" placeholder="12445 (default)">
|
|
79
|
+
</div>
|
|
63
80
|
<div class="form-row">
|
|
64
81
|
<label for="node-config-input-apiToken"><i class="fa fa-key"></i> API Token</label>
|
|
65
82
|
<input type="password" id="node-config-input-apiToken" placeholder="Paste your UniFi Access token">
|
|
@@ -84,6 +101,7 @@
|
|
|
84
101
|
|
|
85
102
|
<h3>Configuration</h3>
|
|
86
103
|
<p><b>Controller</b> accepts the UniFi Access host or <code>host:port</code>. If you omit the port, the node uses the default UniFi Access port automatically.</p>
|
|
104
|
+
<p><b>Port</b> is optional. Leave it empty to use the default <code>12445</code>. Set it when your UniFi Access controller listens on a custom port. A port embedded directly in the Controller field (<code>host:port</code>) takes precedence over this field.</p>
|
|
87
105
|
<p><b>API Token</b> is the bearer token used for authentication.</p>
|
|
88
106
|
<p><b>Security</b> controls certificate verification. Disable it only when your controller uses a self-signed certificate.</p>
|
|
89
107
|
<p><b>Name</b> is the config node name shown in the editor.</p>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
4
|
buildBaseUrlFromHost,
|
|
5
|
+
normalizePort,
|
|
5
6
|
buildQueryString,
|
|
6
7
|
doRequest,
|
|
7
8
|
buildRequestHeaders,
|
|
@@ -67,7 +68,8 @@ module.exports = function(RED) {
|
|
|
67
68
|
const node = this;
|
|
68
69
|
node.name = config.name;
|
|
69
70
|
node.host = String(config.host || "").trim();
|
|
70
|
-
node.
|
|
71
|
+
node.port = normalizePort(config.port);
|
|
72
|
+
node.baseUrl = buildBaseUrlFromHost(node.host, node.port);
|
|
71
73
|
node.rejectUnauthorized = config.rejectUnauthorized !== false && config.rejectUnauthorized !== "false";
|
|
72
74
|
node.nodeClients = [];
|
|
73
75
|
node.wsNotifications = null;
|
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
defaults: {
|
|
8
8
|
name: { value: "Unifi Network Config" },
|
|
9
9
|
host: { value: "", required: true },
|
|
10
|
+
port: {
|
|
11
|
+
value: "",
|
|
12
|
+
required: false,
|
|
13
|
+
validate: function (value) {
|
|
14
|
+
if (value === undefined || value === null || value === "") {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return /^\d+$/.test(String(value)) && Number(value) >= 1 && Number(value) <= 65535;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
10
20
|
rejectUnauthorized: { value: false },
|
|
11
21
|
powerObservationIntervalSeconds: {
|
|
12
22
|
value: 15,
|
|
@@ -28,9 +38,11 @@
|
|
|
28
38
|
oneditprepare: function () {
|
|
29
39
|
const node = this;
|
|
30
40
|
const $hostInput = $("#node-config-input-host");
|
|
41
|
+
const $port = $("#node-config-input-port");
|
|
31
42
|
const $apiKey = $("#node-config-input-apiKey");
|
|
32
43
|
const $rejectUnauthorized = $("#node-config-input-rejectUnauthorized");
|
|
33
44
|
const $powerObservationIntervalSeconds = $("#node-config-input-powerObservationIntervalSeconds");
|
|
45
|
+
const $portRow = $port.closest(".form-row");
|
|
34
46
|
const $apiKeyRow = $apiKey.closest(".form-row");
|
|
35
47
|
const $securityRow = $rejectUnauthorized.closest(".form-row");
|
|
36
48
|
const $powerObservationRow = $powerObservationIntervalSeconds.closest(".form-row");
|
|
@@ -38,6 +50,7 @@
|
|
|
38
50
|
|
|
39
51
|
function syncProgressiveRows() {
|
|
40
52
|
const hasHost = String($hostInput.val() || node.host || "").trim() !== "";
|
|
53
|
+
$portRow.toggle(hasHost);
|
|
41
54
|
$apiKeyRow.toggle(hasHost);
|
|
42
55
|
$securityRow.toggle(hasHost);
|
|
43
56
|
$powerObservationRow.toggle(hasHost);
|
|
@@ -73,6 +86,10 @@
|
|
|
73
86
|
<label for="node-config-input-host"><i class="fa fa-globe"></i> Controller</label>
|
|
74
87
|
<input type="text" id="node-config-input-host" placeholder="192.168.1.10">
|
|
75
88
|
</div>
|
|
89
|
+
<div class="form-row">
|
|
90
|
+
<label for="node-config-input-port"><i class="fa fa-plug"></i> Port</label>
|
|
91
|
+
<input type="text" id="node-config-input-port" placeholder="443 (default)">
|
|
92
|
+
</div>
|
|
76
93
|
<div class="form-row">
|
|
77
94
|
<label for="node-config-input-apiKey"><i class="fa fa-key"></i> API Key</label>
|
|
78
95
|
<input type="password" id="node-config-input-apiKey" placeholder="Paste your UniFi Network API key">
|
|
@@ -101,6 +118,7 @@
|
|
|
101
118
|
|
|
102
119
|
<h3>Configuration</h3>
|
|
103
120
|
<p><b>Controller</b> accepts the UniFi OS host or IP address. The node builds the local UniFi Network proxy URL automatically.</p>
|
|
121
|
+
<p><b>Port</b> is optional. Leave it empty to use the default <code>443</code>. Set it when your UniFi OS server listens on a custom port (for example <code>11443</code>). A port embedded directly in the Controller field (<code>host:port</code>) takes precedence over this field.</p>
|
|
104
122
|
<p><b>API Key</b> is required for authentication and is sent as <code>X-API-Key</code>.</p>
|
|
105
123
|
<p><b>Security</b> controls certificate verification. Disable it only when your controller uses a self-signed certificate.</p>
|
|
106
124
|
<p><b>Power Poll (s)</b> is the global polling interval used by all <code>Control POE</code> nodes when action is <code>Emit Power Consumption</code>. It is optional and defaults to 15 seconds.</p>
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
4
|
buildBaseUrlFromHost,
|
|
5
|
+
normalizePort,
|
|
6
|
+
applyPortToHost,
|
|
5
7
|
buildQueryString,
|
|
6
8
|
doRequest,
|
|
7
9
|
buildRequestHeaders,
|
|
@@ -75,7 +77,8 @@ module.exports = function(RED) {
|
|
|
75
77
|
const node = this;
|
|
76
78
|
node.name = config.name;
|
|
77
79
|
node.host = String(config.host || "").trim();
|
|
78
|
-
node.
|
|
80
|
+
node.port = normalizePort(config.port);
|
|
81
|
+
node.baseUrl = buildBaseUrlFromHost(node.host, node.port);
|
|
79
82
|
node.rejectUnauthorized = config.rejectUnauthorized !== false && config.rejectUnauthorized !== "false";
|
|
80
83
|
node.powerObservationIntervalSeconds = normalizePowerObserverIntervalSeconds(config.powerObservationIntervalSeconds);
|
|
81
84
|
node.nodeClients = [];
|
|
@@ -642,10 +645,13 @@ module.exports = function(RED) {
|
|
|
642
645
|
};
|
|
643
646
|
|
|
644
647
|
node.buildUnofficialNetworkWebSocketUrl = () => {
|
|
645
|
-
const normalizedHost =
|
|
646
|
-
.
|
|
647
|
-
|
|
648
|
-
|
|
648
|
+
const normalizedHost = applyPortToHost(
|
|
649
|
+
String(node.host || "")
|
|
650
|
+
.trim()
|
|
651
|
+
.replace(/^https?:\/\//i, "")
|
|
652
|
+
.replace(/\/.*$/, ""),
|
|
653
|
+
node.port
|
|
654
|
+
);
|
|
649
655
|
if (!normalizedHost) {
|
|
650
656
|
throw new Error("The configured host is empty or invalid.");
|
|
651
657
|
}
|
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
defaults: {
|
|
8
8
|
name: { value: "Unifi Protect Config" },
|
|
9
9
|
host: { value: "", required: true },
|
|
10
|
+
port: {
|
|
11
|
+
value: "",
|
|
12
|
+
required: false,
|
|
13
|
+
validate: function (value) {
|
|
14
|
+
if (value === undefined || value === null || value === "") {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return /^\d+$/.test(String(value)) && Number(value) >= 1 && Number(value) <= 65535;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
10
20
|
authHeader: { value: "X-API-Key", required: true },
|
|
11
21
|
rejectUnauthorized: { value: false }
|
|
12
22
|
},
|
|
@@ -19,14 +29,17 @@
|
|
|
19
29
|
oneditprepare: function () {
|
|
20
30
|
const node = this;
|
|
21
31
|
const $hostInput = $("#node-config-input-host");
|
|
32
|
+
const $port = $("#node-config-input-port");
|
|
22
33
|
const $apiKey = $("#node-config-input-apiKey");
|
|
23
34
|
const $rejectUnauthorized = $("#node-config-input-rejectUnauthorized");
|
|
35
|
+
const $portRow = $port.closest(".form-row");
|
|
24
36
|
const $apiKeyRow = $apiKey.closest(".form-row");
|
|
25
37
|
const $securityRow = $rejectUnauthorized.closest(".form-row");
|
|
26
38
|
const $advancedRow = $("#node-config-row-advanced");
|
|
27
39
|
|
|
28
40
|
function syncProgressiveRows() {
|
|
29
41
|
const hasHost = String($hostInput.val() || node.host || "").trim() !== "";
|
|
42
|
+
$portRow.toggle(hasHost);
|
|
30
43
|
$apiKeyRow.toggle(hasHost);
|
|
31
44
|
$securityRow.toggle(hasHost);
|
|
32
45
|
$advancedRow.toggle(hasHost);
|
|
@@ -63,6 +76,10 @@
|
|
|
63
76
|
<label for="node-config-input-host"><i class="fa fa-globe"></i> Controller</label>
|
|
64
77
|
<input type="text" id="node-config-input-host" placeholder="192.168.1.10">
|
|
65
78
|
</div>
|
|
79
|
+
<div class="form-row">
|
|
80
|
+
<label for="node-config-input-port"><i class="fa fa-plug"></i> Port</label>
|
|
81
|
+
<input type="text" id="node-config-input-port" placeholder="443 (default)">
|
|
82
|
+
</div>
|
|
66
83
|
<div class="form-row">
|
|
67
84
|
<label for="node-config-input-apiKey"><i class="fa fa-key"></i> API Key</label>
|
|
68
85
|
<input type="password" id="node-config-input-apiKey" placeholder="Paste your UniFi Protect API key">
|
|
@@ -91,6 +108,7 @@
|
|
|
91
108
|
|
|
92
109
|
<h3>Configuration</h3>
|
|
93
110
|
<p><b>Controller</b> accepts the UniFi OS host or IP address. The node builds the Protect integration URL automatically.</p>
|
|
111
|
+
<p><b>Port</b> is optional. Leave it empty to use the default <code>443</code>. Set it when your UniFi OS server listens on a custom port (for example <code>11443</code>). A port embedded directly in the Controller field (<code>host:port</code>) takes precedence over this field.</p>
|
|
94
112
|
<p><b>API Key</b> is required for authentication.</p>
|
|
95
113
|
<p><b>Security</b> controls certificate verification. Disable it only when your controller uses a self-signed certificate.</p>
|
|
96
114
|
<p><b>Name</b> is the config node name shown in the editor.</p>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
4
|
buildBaseUrlFromHost,
|
|
5
|
+
normalizePort,
|
|
5
6
|
buildQueryString,
|
|
6
7
|
doRequest,
|
|
7
8
|
buildRequestHeaders,
|
|
@@ -24,7 +25,8 @@ module.exports = function(RED) {
|
|
|
24
25
|
const node = this;
|
|
25
26
|
node.name = config.name;
|
|
26
27
|
node.host = String(config.host || "").trim();
|
|
27
|
-
node.
|
|
28
|
+
node.port = normalizePort(config.port);
|
|
29
|
+
node.baseUrl = buildBaseUrlFromHost(node.host, node.port);
|
|
28
30
|
node.authHeader = (config.authHeader || "X-API-Key").trim() || "X-API-Key";
|
|
29
31
|
node.rejectUnauthorized = config.rejectUnauthorized !== false && config.rejectUnauthorized !== "false";
|
|
30
32
|
node.nodeClients = [];
|
|
@@ -12,6 +12,57 @@ function parseIntervalSeconds(value, fallback) {
|
|
|
12
12
|
return Math.trunc(numeric);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
function normalizePort(value) {
|
|
16
|
+
// Accept a TCP port from the editor and reduce it to a clean "1".."65535"
|
|
17
|
+
// string, or empty when missing/invalid so callers can fall back to defaults.
|
|
18
|
+
if (value === undefined || value === null) {
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const str = String(value).trim();
|
|
23
|
+
if (!str || !/^\d+$/.test(str)) {
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const num = Number(str);
|
|
28
|
+
if (!Number.isInteger(num) || num < 1 || num > 65535) {
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return String(num);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function hostHasExplicitPort(host) {
|
|
36
|
+
if (!host) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (host.startsWith("[")) {
|
|
41
|
+
// IPv6 literal: a port is only present when "]:" appears (e.g. [::1]:443).
|
|
42
|
+
return host.includes("]:");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Bare host or IPv4: a single trailing :<digits> is a port.
|
|
46
|
+
return (host.match(/:/g) || []).length === 1 && /:\d+$/.test(host);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function applyPortToHost(host, port) {
|
|
50
|
+
// Combine a normalized host with the dedicated port field. A port already
|
|
51
|
+
// embedded in the host string always wins, so the separate field only fills
|
|
52
|
+
// the gap when the host carries none.
|
|
53
|
+
const normalizedHost = String(host || "").trim();
|
|
54
|
+
if (!normalizedHost) {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const normalizedPort = normalizePort(port);
|
|
59
|
+
if (!normalizedPort || hostHasExplicitPort(normalizedHost)) {
|
|
60
|
+
return normalizedHost;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return `${normalizedHost}:${normalizedPort}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
15
66
|
function buildStatusTimestampText() {
|
|
16
67
|
const now = new Date();
|
|
17
68
|
const time = now.toTimeString().split(" ")[0];
|
|
@@ -93,6 +144,8 @@ function buildErrorOutputMessage(error, nodeName) {
|
|
|
93
144
|
module.exports = {
|
|
94
145
|
parseBoolean,
|
|
95
146
|
parseIntervalSeconds,
|
|
147
|
+
normalizePort,
|
|
148
|
+
applyPortToHost,
|
|
96
149
|
buildStatusTimestampText,
|
|
97
150
|
appendStatusTimestamp,
|
|
98
151
|
resolveNodeName,
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
const http = require("http");
|
|
4
4
|
const https = require("https");
|
|
5
5
|
const { maybeParseBody } = require("./http-response-utils");
|
|
6
|
+
const { normalizePort, applyPortToHost } = require("./common-utils");
|
|
6
7
|
|
|
7
|
-
function normalizeHost(value) {
|
|
8
|
+
function normalizeHost(value, port) {
|
|
8
9
|
// Access controllers usually live on port 12445. Accept bare hosts, host:port
|
|
9
|
-
// pairs and IPv6 literals, then normalize everything to one safe form.
|
|
10
|
+
// pairs and IPv6 literals, then normalize everything to one safe form. The
|
|
11
|
+
// dedicated port field (when set) fills in a missing port before the 12445
|
|
12
|
+
// default is applied.
|
|
10
13
|
let host = String(value || "").trim();
|
|
11
14
|
if (!host) {
|
|
12
15
|
return "";
|
|
@@ -20,6 +23,8 @@ function normalizeHost(value) {
|
|
|
20
23
|
return "";
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
host = applyPortToHost(host, port);
|
|
27
|
+
|
|
23
28
|
if (host.startsWith("[") && host.includes("]")) {
|
|
24
29
|
return host.includes("]:") ? host : `${host}:12445`;
|
|
25
30
|
}
|
|
@@ -36,8 +41,8 @@ function normalizeHost(value) {
|
|
|
36
41
|
return host;
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
function buildBaseUrlFromHost(value) {
|
|
40
|
-
const host = normalizeHost(value);
|
|
44
|
+
function buildBaseUrlFromHost(value, port) {
|
|
45
|
+
const host = normalizeHost(value, port);
|
|
41
46
|
if (!host) {
|
|
42
47
|
return "";
|
|
43
48
|
}
|
|
@@ -174,6 +179,8 @@ function normalizeAccessCollection(payload) {
|
|
|
174
179
|
|
|
175
180
|
module.exports = {
|
|
176
181
|
buildBaseUrlFromHost,
|
|
182
|
+
normalizePort,
|
|
183
|
+
applyPortToHost,
|
|
177
184
|
buildQueryString,
|
|
178
185
|
doRequest,
|
|
179
186
|
buildRequestHeaders,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const http = require("http");
|
|
4
4
|
const https = require("https");
|
|
5
5
|
const { maybeParseBody } = require("./http-response-utils");
|
|
6
|
+
const { normalizePort, applyPortToHost } = require("./common-utils");
|
|
6
7
|
|
|
7
8
|
function normalizeHost(value) {
|
|
8
9
|
// Accept either a bare host or a full URL from the editor and reduce it to
|
|
@@ -17,8 +18,8 @@ function normalizeHost(value) {
|
|
|
17
18
|
return host.trim().replace(/\/+$/, "");
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
function buildBaseUrlFromHost(value) {
|
|
21
|
-
const host = normalizeHost(value);
|
|
21
|
+
function buildBaseUrlFromHost(value, port) {
|
|
22
|
+
const host = applyPortToHost(normalizeHost(value), port);
|
|
22
23
|
if (!host) {
|
|
23
24
|
return "";
|
|
24
25
|
}
|
|
@@ -156,6 +157,8 @@ function normalizeNetworkCollection(payload) {
|
|
|
156
157
|
|
|
157
158
|
module.exports = {
|
|
158
159
|
buildBaseUrlFromHost,
|
|
160
|
+
normalizePort,
|
|
161
|
+
applyPortToHost,
|
|
159
162
|
buildQueryString,
|
|
160
163
|
doRequest,
|
|
161
164
|
buildRequestHeaders,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const http = require("http");
|
|
4
4
|
const https = require("https");
|
|
5
5
|
const { maybeParseBody } = require("./http-response-utils");
|
|
6
|
+
const { normalizePort, applyPortToHost } = require("./common-utils");
|
|
6
7
|
|
|
7
8
|
function normalizeHost(value) {
|
|
8
9
|
// Protect editor fields may contain a host or a full URL; strip everything
|
|
@@ -17,8 +18,8 @@ function normalizeHost(value) {
|
|
|
17
18
|
return host.trim().replace(/\/+$/, "");
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
function buildBaseUrlFromHost(value) {
|
|
21
|
-
const host = normalizeHost(value);
|
|
21
|
+
function buildBaseUrlFromHost(value, port) {
|
|
22
|
+
const host = applyPortToHost(normalizeHost(value), port);
|
|
22
23
|
if (!host) {
|
|
23
24
|
return "";
|
|
24
25
|
}
|
|
@@ -131,6 +132,8 @@ function buildRequestBody(headers, method, payload) {
|
|
|
131
132
|
|
|
132
133
|
module.exports = {
|
|
133
134
|
buildBaseUrlFromHost,
|
|
135
|
+
normalizePort,
|
|
136
|
+
applyPortToHost,
|
|
134
137
|
buildQueryString,
|
|
135
138
|
doRequest,
|
|
136
139
|
buildRequestHeaders,
|
package/package.json
CHANGED