@@ -4,7 +4,7 @@ import { useGenericGlobalsStore } from './genericGlobals';
44import axios from 'axios' ;
55
66export const useCveListSearchStore = defineStore ( 'cveListSearch ' , {
7- state : ( ) => {
7+ state : ( ) => {
88 return {
99 cveId : '' ,
1010 from : 0 ,
@@ -84,15 +84,36 @@ export const useCveListSearchStore = defineStore('cveListSearch ', {
8484 this . totalExecutingRequests = 1 ;
8585 await this . getSearchResults ( ) ;
8686
87- // * Check if keyword is CVE ID
8887 if ( this . isCveIdPattern ( ) ) {
89- this . totalExecutingRequests = 2 ;
90-
91- // lookup ID to get Record data
88+
89+ // The user's query is one CVE ID.
90+
9291 this . cveId = this . query . toUpperCase ( ) ;
93- await this . getRecordData ( ) ;
94- }
9592
93+ if ( this . searchResults . length === 1
94+ && this . searchResults [ 0 ] . cveId === this . cveId ) {
95+
96+ // The search returned only ONE result and it's the CVE record
97+ // associated with the CVE ID given as the search string. Most
98+ // likely, the user just wants to see the CVE Record and not the
99+ // search results containing only the CVE link for the record
100+ // they're searching for (just to have to click on the CVE link to
101+ // get to the CVE Record). In this case, change the route to
102+ // go directly to the CVE Record display.
103+
104+ this . router . push ( {
105+ name : 'CVERecord' ,
106+ query : { id : this . cveId } ,
107+ replace : true
108+ } ) ;
109+ } else {
110+
111+ this . totalExecutingRequests = 2 ;
112+
113+ // lookup ID to get Record data
114+ await this . getRecordData ( ) ;
115+ }
116+ }
96117 } catch ( error ) {
97118 // if record is not found, find potential reserved/rejected ID
98119 if ( this . isCveIdPattern ( ) && Object . keys ( this . recordData ) . length === 0 ) {
@@ -306,7 +327,7 @@ export const useCveListSearchStore = defineStore('cveListSearch ', {
306327 async paginate ( ) {
307328 try {
308329 this . calcToAndFromCounts ( ) ;
309-
330+
310331 // search service starts at 0 while this app starts at 1
311332 this . from = ( parseInt ( this . pagination . currentPage ) * parseInt ( this . pagination . numberPerPage ) ) - parseInt ( this . pagination . numberPerPage ) ;
312333 if ( parseInt ( this . from ) + parseInt ( this . pagination . numberPerPage ) > parseInt ( this . totalSearchResultCount ) ) {
@@ -414,7 +435,7 @@ export const useCveListSearchStore = defineStore('cveListSearch ', {
414435
415436 this . pagination . currentPageWindow = this . calcRange ( this . pagination . startWindow , this . pagination . endWindow ) ;
416437 this . paginate ( ) ;
417- }
438+ }
418439 } ,
419440 handleNextPageChange ( ) {
420441 this . pagination . currentPage = parseInt ( this . pagination . currentPage ) + 1 ;
0 commit comments