Skip to content

Commit d7bb7c7

Browse files
committed
add nodered_domain_schema support
1 parent e2ce4bc commit d7bb7c7

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

OpenFlowNodeRED/src/Config.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export class Config {
1818
public static tls_passphrase: string = Config.getEnv("tls_passphrase", "");
1919
public static port: number = parseInt(Config.getEnv("port", "1880"));
2020
public static domain: string = Config.getEnv("domain", "localhost");
21+
public static nodered_domain_schema: string = Config.getEnv("nodered_domain_schema", "");
22+
2123
public static api_ws_url: string = Config.getEnv("api_ws_url", "ws://localhost:3000");
2224
public static amqp_url: string = Config.getEnv("amqp_url", "amqp://localhost");
2325

@@ -27,6 +29,11 @@ export class Config {
2729
public static aes_secret: string = Config.getEnv("aes_secret", "");
2830

2931
public static baseurl(): string {
32+
var matches = Config.nodered_id.match(/\d+/);
33+
Config.nodered_id = matches[matches.length - 1]; // Just grab the last number
34+
if (Config.nodered_domain_schema != "") {
35+
Config.domain = Config.nodered_domain_schema.replace("$nodered_id$", Config.nodered_id)
36+
}
3037
if (Config.tls_crt != '' && Config.tls_key != '') {
3138
return "https://" + Config.domain + ":" + Config.port + "/";
3239
}
@@ -38,8 +45,8 @@ export class Config {
3845
if (!value || value === "") { value = defaultvalue; }
3946
return value;
4047
}
41-
public static parseBoolean(s:any):boolean {
42-
var val:string = "false";
48+
public static parseBoolean(s: any): boolean {
49+
var val: string = "false";
4350
if (typeof s === "number") {
4451
val = s.toString();
4552
} else if (typeof s === "string") {
@@ -49,7 +56,7 @@ export class Config {
4956
} else {
5057
throw new Error("Unknown type!");
5158
}
52-
switch(val) {
59+
switch (val) {
5360
case "true": case "yes": case "1": return true;
5461
case "false": case "no": case "0": case null: return false;
5562
default: return Boolean(s);

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.93
1+
0.0.94

0 commit comments

Comments
 (0)