|
31 | 31 | <h4 class="title">Find the CVE Numbering Authority (CNA)</h4> |
32 | 32 | <p> |
33 | 33 | Find the CNA partner whose scope includes the product affected by the vulnerability on the |
34 | | - <router-link to="/PartnerInformation/ListofPartners">List of Partners</router-link> page or in the search box below. |
| 34 | + <router-link to="/PartnerInformation/ListofPartners">List of Partners</router-link> |
| 35 | + page or in the search box below. |
35 | 36 | </p> |
36 | 37 | <b-field> |
37 | 38 | <b-autocomplete |
@@ -188,17 +189,34 @@ export default { |
188 | 189 | }, |
189 | 190 | computed: { |
190 | 191 | filteredDataObj() { |
191 | | - const results = this.data.filter((option) => ( |
192 | | - option.organizationName |
193 | | - .toString() |
194 | | - .toLowerCase() |
195 | | - .indexOf(this.name.toLowerCase()) >= 0 |
196 | | - )); |
| 192 | + const normalizedName = this.name.toLowerCase(); |
| 193 | + if (!normalizedName.length) |
| 194 | + return; |
197 | 195 |
|
198 | | - if (results.length > 10) { |
199 | | - return results.splice(0, 10); |
| 196 | + let results = this.data.filter((option) => ( |
| 197 | + option.organizationName.toLowerCase() |
| 198 | + .indexOf(normalizedName) >= 0)); |
| 199 | +
|
| 200 | + function cmp(cna1, cna2) { |
| 201 | + // Sorts the list of organization names based on the characters |
| 202 | + // entered by the user in the search box. For example, if the user |
| 203 | + // has entered "br", then "Brocade Communications" is listed before |
| 204 | + // "Jetbrains" because "br" is closest to the beginning of the |
| 205 | + // string in "Brocade Communications". |
| 206 | +
|
| 207 | + const cna1NormalName = cna1.organizationName.toLowerCase(); |
| 208 | + const cna2NormalName = cna2.organizationName.toLowerCase() |
| 209 | + const cna1Index = cna1NormalName.indexOf(normalizedName); |
| 210 | + const cna2Index = cna2NormalName.indexOf(normalizedName); |
| 211 | +
|
| 212 | + return cna1Index < cna2Index ? -1 : cna1Index > cna2Index ? 1 : |
| 213 | + cna1NormalName.localeCompare(cna2NormalName); |
200 | 214 | } |
201 | | - return results; |
| 215 | +
|
| 216 | + // Limit the choices presented to the user to the first 10 organizations |
| 217 | + // in the list. |
| 218 | +
|
| 219 | + return results.sort(cmp).slice(0, 10); |
202 | 220 | }, |
203 | 221 | }, |
204 | 222 | methods: { |
|
0 commit comments