Commit 77b64b0 2 people authored and committed
1 parent bc90e93 commit 77b64b0 Copy full SHA for 77b64b0
File tree 4 files changed +39
-10
lines changed
4 files changed +39
-10
lines changed Original file line number Diff line number Diff line change @@ -912,10 +912,20 @@ export class QueryDetail extends React.Component {
912
912
}
913
913
}
914
914
915
+ static getQueryURL ( id ) {
916
+ if ( ! id || typeof id !== 'string' || id . length === 0 ) {
917
+ return "/v1/query/undefined" ;
918
+ }
919
+ const sanitizedId = id . replace ( / [ ^ a - z 0 - 9 _ ] / gi, '' ) ;
920
+ return sanitizedId . length > 0 ? `/v1/query/${ encodeURIComponent ( sanitizedId ) } ` : "/v1/query/undefined" ;
921
+ }
922
+
923
+
915
924
refreshLoop ( ) {
916
925
clearTimeout ( this . timeoutId ) ; // to stop multiple series of refreshLoop from going on simultaneously
917
- const queryId = getFirstParameter ( window . location . search ) ;
918
- $ . get ( '/v1/query/' + queryId , function ( query ) {
926
+ const queryId = getFirstParameter ( window . location . search ) ;
927
+
928
+ $ . get ( QueryDetail . getQueryURL ( queryId ) , function ( query ) {
919
929
let lastSnapshotStages = this . state . lastSnapshotStage ;
920
930
if ( this . state . stageRefresh ) {
921
931
lastSnapshotStages = query . outputStage ;
Original file line number Diff line number Diff line change @@ -506,12 +506,18 @@ export class StageDetail extends React.Component {
506
506
this . timeoutId = setTimeout ( this . refreshLoop , 1000 ) ;
507
507
}
508
508
}
509
+ static getQueryURL ( id ) {
510
+ if ( ! id || typeof id !== 'string' || id . length === 0 ) {
511
+ return "/v1/query/undefined" ;
512
+ }
513
+ const sanitizedId = id . replace ( / [ ^ a - z 0 - 9 _ ] / gi, '' ) ;
514
+ return sanitizedId . length > 0 ? `/v1/query/${ encodeURIComponent ( sanitizedId ) } ` : "/v1/query/undefined" ;
515
+ }
509
516
510
517
refreshLoop ( ) {
511
518
clearTimeout ( this . timeoutId ) ; // to stop multiple series of refreshLoop from going on simultaneously
512
519
const queryString = getFirstParameter ( window . location . search ) . split ( '.' ) ;
513
- const queryId = queryString . length > 0 ? queryString [ 0 ] : "undefined" ;
514
-
520
+ const rawQueryId = queryString . length > 0 ? queryString [ 0 ] : "" ;
515
521
let selectedStageId = this . state . selectedStageId ;
516
522
if ( selectedStageId === null ) {
517
523
selectedStageId = 0 ;
@@ -520,7 +526,8 @@ export class StageDetail extends React.Component {
520
526
}
521
527
}
522
528
523
- $ . get ( '/v1/query/' + queryId , query => {
529
+
530
+ $ . get ( StageDetail . getQueryURL ( rawQueryId ) , query => {
524
531
this . setState ( {
525
532
initialized : true ,
526
533
ended : query . finalQueryInfo ,
Original file line number Diff line number Diff line change @@ -50,11 +50,18 @@ export class WorkerStatus extends React.Component {
50
50
this . timeoutId = setTimeout ( this . refreshLoop , 1000 ) ;
51
51
}
52
52
}
53
+ static getStatusQuery ( id ) {
54
+ // Node ID does not have a common pattern
55
+ if ( id . length === 0 ) {
56
+ return "/v1/worker/undefined/status" ;
57
+ }
58
+ return `/v1/worker/${ encodeURIComponent ( id ) } /status` ;
59
+ }
53
60
54
61
refreshLoop ( ) {
55
62
clearTimeout ( this . timeoutId ) ; // to stop multiple series of refreshLoop from going on simultaneously
56
- const nodeId = getFirstParameter ( window . location . search ) ;
57
- $ . get ( '/v1/worker/' + nodeId + '/status' , function ( serverInfo ) {
63
+
64
+ $ . get ( WorkerStatus . getStatusQuery ( getFirstParameter ( window . location . search ) ) , function ( serverInfo ) {
58
65
this . setState ( {
59
66
serverInfo : serverInfo ,
60
67
initialized : true ,
Original file line number Diff line number Diff line change @@ -40,10 +40,15 @@ export class WorkerThreadList extends React.Component {
40
40
selectedThreadState : ALL_THREAD_STATE ,
41
41
} ;
42
42
}
43
-
43
+ static getRequestQuery ( id ) {
44
+ // Node ID does not have a common pattern
45
+ if ( id . length === 0 ) {
46
+ return "/v1/worker/undefined/thread" ;
47
+ }
48
+ return `/v1/worker/${ encodeURIComponent ( id ) } /thread` ;
49
+ }
44
50
captureSnapshot ( ) {
45
- const nodeId = getFirstParameter ( window . location . search ) ;
46
- $ . get ( '/v1/worker/' + nodeId + '/thread' , function ( threads ) {
51
+ $ . get ( WorkerThreadList . getRequestQuery ( getFirstParameter ( window . location . search ) ) , function ( threads ) {
47
52
this . setState ( {
48
53
threads : WorkerThreadList . processThreads ( threads ) ,
49
54
snapshotTime : new Date ( ) ,
You can’t perform that action at this time.
0 commit comments