File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ export class Config {
3131
3232 public static baseurl ( ) : string {
3333 var matches = Config . nodered_id . match ( / \d + / ) ;
34- Config . nodered_id = matches [ matches . length - 1 ] ; // Just grab the last number
34+ if ( matches . length > 0 ) {
35+ Config . nodered_id = matches [ matches . length - 1 ] ; // Just grab the last number
36+ }
3537 if ( Config . nodered_domain_schema != "" ) {
3638 Config . domain = Config . nodered_domain_schema . replace ( "$nodered_id$" , Config . nodered_id )
3739 }
Original file line number Diff line number Diff line change @@ -32,14 +32,21 @@ process.on('unhandledRejection', up => {
3232 console . error ( up ) ;
3333 throw up
3434} ) ;
35-
35+ function isNumeric ( n ) {
36+ return ! isNaN ( parseFloat ( n ) ) && isFinite ( n ) ;
37+ }
3638( async function ( ) : Promise < void > {
3739 try {
3840 var socket : WebSocketClient = new WebSocketClient ( logger , Config . api_ws_url ) ;
3941 socket . events . on ( "onopen" , async ( ) => {
4042
4143 var q : SigninMessage = new SigninMessage ( ) ;
42- var user = new TokenUser ( ) ; user . name = "nodered" + Config . nodered_id ; user . username = user . name ;
44+ var user = new TokenUser ( ) ;
45+ user . name = "nodered" + Config . nodered_id ;
46+ if ( ! isNumeric ( Config . nodered_id ) ) {
47+ user . name = Config . nodered_id ;
48+ }
49+ user . username = user . name ;
4350 q . jwt = Crypt . createToken ( user ) ;
4451 var msg : Message = new Message ( ) ; msg . command = "signin" ; msg . data = JSON . stringify ( q ) ;
4552 var result : SigninMessage = await socket . Send < SigninMessage > ( msg ) ;
Original file line number Diff line number Diff line change 1- 0.0.170
1+ 0.0.171
You can’t perform that action at this time.
0 commit comments