@@ -206,6 +206,7 @@ func ScanAndPrintResult(client *http.Client, repo RepoSearchResult) {
206206 color .New (color .Faint ).Println ("query: " + repo .Query )
207207 }
208208 }
209+
209210 if GetFlags ().Dashboard && GetFlags ().InsertKey != "" {
210211 resultJSON , err := json .Marshal (resultPayload )
211212 if err == nil {
@@ -463,42 +464,36 @@ func ScanAndPrintResult(client *http.Client, repo RepoSearchResult) {
463464 }
464465 }
465466 }
467+
468+ // Handle dashboard mode for match-query results
466469 if GetFlags ().Dashboard && GetFlags ().InsertKey != "" {
467470 resultJSON , err := json .Marshal (resultPayload )
468471 if err == nil {
469472 searchID := GetFlags ().SearchID
470473 if searchID != "" {
471- if GetFlags ().Trufflehog {
472- SendMessageToWebSocket (fmt .Sprintf (`{"event": "search_result", "insertToken": "%s", "searchID": "%s", "result": %s}` , GetFlags ().InsertKey , searchID , string (resultJSON )))
473- } else {
474- escapedQuery , _ := json .Marshal (repo .Query )
475- // For dig-files matches, ensure the file path and URL are correctly set
476- if len (result .Attributes ) > 0 && result .Attributes [0 ] == "dig-files" {
477- resultPayload ["file" ] = result .File
478- baseURL := strings .Split (repo .URL , "/blob/" )[0 ]
479- commitHash := strings .Split (repo .URL , "/blob/" )[1 ]
480- commitHash = strings .Split (commitHash , "/" )[0 ]
481- resultPayload ["url" ] = fmt .Sprintf ("%s/blob/%s/%s" , baseURL , commitHash , result .File )
482- resultJSON , _ = json .Marshal (resultPayload )
483- }
484- SendMessageToWebSocket (fmt .Sprintf (`{"event": "search_result", "insertToken": "%s", "searchID": "%s", "result": %s, "search_term": %s}` , GetFlags ().InsertKey , searchID , string (resultJSON ), string (escapedQuery )))
474+ escapedQuery , _ := json .Marshal (repo .Query )
475+ // For dig-files matches, ensure the file path and URL are correctly set
476+ if len (result .Attributes ) > 0 && result .Attributes [0 ] == "dig-files" {
477+ resultPayload ["file" ] = result .File
478+ baseURL := strings .Split (repo .URL , "/blob/" )[0 ]
479+ commitHash := strings .Split (repo .URL , "/blob/" )[1 ]
480+ commitHash = strings .Split (commitHash , "/" )[0 ]
481+ resultPayload ["url" ] = fmt .Sprintf ("%s/blob/%s/%s" , baseURL , commitHash , result .File )
482+ resultJSON , _ = json .Marshal (resultPayload )
485483 }
484+ SendMessageToWebSocket (fmt .Sprintf (`{"event": "search_result", "insertToken": "%s", "searchID": "%s", "result": %s, "search_term": %s}` , GetFlags ().InsertKey , searchID , string (resultJSON ), string (escapedQuery )))
486485 } else {
487- if GetFlags ().Trufflehog {
488- SendMessageToWebSocket (fmt .Sprintf (`{"event": "search_result", "insertToken": "%s", "result": %s}` , GetFlags ().InsertKey , string (resultJSON )))
489- } else {
490- escapedQuery , _ := json .Marshal (repo .Query )
491- // For dig-files matches, ensure the file path and URL are correctly set
492- if len (result .Attributes ) > 0 && result .Attributes [0 ] == "dig-files" {
493- resultPayload ["file" ] = result .File
494- baseURL := strings .Split (repo .URL , "/blob/" )[0 ]
495- commitHash := strings .Split (repo .URL , "/blob/" )[1 ]
496- commitHash = strings .Split (commitHash , "/" )[0 ]
497- resultPayload ["url" ] = fmt .Sprintf ("%s/blob/%s/%s" , baseURL , commitHash , result .File )
498- resultJSON , _ = json .Marshal (resultPayload )
499- }
500- SendMessageToWebSocket (fmt .Sprintf (`{"event": "search_result", "insertToken": "%s", "result": %s, "search_term": %s}` , GetFlags ().InsertKey , string (resultJSON ), string (escapedQuery )))
486+ escapedQuery , _ := json .Marshal (repo .Query )
487+ // For dig-files matches, ensure the file path and URL are correctly set
488+ if len (result .Attributes ) > 0 && result .Attributes [0 ] == "dig-files" {
489+ resultPayload ["file" ] = result .File
490+ baseURL := strings .Split (repo .URL , "/blob/" )[0 ]
491+ commitHash := strings .Split (repo .URL , "/blob/" )[1 ]
492+ commitHash = strings .Split (commitHash , "/" )[0 ]
493+ resultPayload ["url" ] = fmt .Sprintf ("%s/blob/%s/%s" , baseURL , commitHash , result .File )
494+ resultJSON , _ = json .Marshal (resultPayload )
501495 }
496+ SendMessageToWebSocket (fmt .Sprintf (`{"event": "search_result", "insertToken": "%s", "result": %s, "search_term": %s}` , GetFlags ().InsertKey , string (resultJSON ), string (escapedQuery )))
502497 }
503498 } else {
504499 color .Red ("Error marshalling result to JSON: %v" , err )
0 commit comments