Skip to content

Commit a1e9a04

Browse files
committed
move VITE_CVE_SERVICES_BASE_URL to genericGlobals
1 parent 693dca6 commit a1e9a04

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/components/cveRecordSearchModule.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ function startSearch() {
139139
// otherwise we should default back to what we were on a page refresh
140140
if (searchTypeBoolean.value) {
141141
cveGenericGlobalsStore.setUseSearch(true);
142-
cveGenericGlobalsStore.setCurrentServicesUrl(`https://${import.meta.env.VITE_CVE_SERVICES_BASE_URL}`)
142+
cveGenericGlobalsStore.setCurrentServicesUrl(cveGenericGlobalsStore.cveServicesBaseUrl);
143143
}
144144
else {
145145
cveGenericGlobalsStore.setUseSearch(false);
146-
cveGenericGlobalsStore.setCurrentServicesUrl(cveGenericGlobalsStore.cveServiceTestBaseUrl)
146+
cveGenericGlobalsStore.setCurrentServicesUrl(cveGenericGlobalsStore.cveServiceTestBaseUrl);
147147
}
148148
if (cveGenericGlobalsStore.useSearch) {
149149
cveListSearchStore.$reset();

src/stores/genericGlobals.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import { defineStore } from 'pinia';
22

33
export const useGenericGlobalsStore = defineStore('genericGlobals', {
44
state: () => {
5+
const cveServicesBaseUrlFromEnv = `https://${import.meta.env.VITE_CVE_SERVICES_BASE_URL}`;
56
const storedUseSearch = sessionStorage.getItem('useSearch');
67
const storedCurrentServicesUrl = sessionStorage.getItem('currentServicesUrl');
78
return {
89
useSearch: storedUseSearch ? JSON.parse(storedUseSearch) : true,
9-
currentServicesUrl: storedCurrentServicesUrl ? JSON.parse(storedCurrentServicesUrl) : `https://${import.meta.env.VITE_CVE_SERVICES_BASE_URL}`,
10+
currentServicesUrl: storedCurrentServicesUrl ? JSON.parse(storedCurrentServicesUrl)
11+
: cveServicesBaseUrlFromEnv,
12+
cveServicesBaseUrl: cveServicesBaseUrlFromEnv,
1013
cveServiceTestBaseUrl: 'https://cveawg-test.mitre.org',
1114
legacyCveWebsiteLink: 'https://cve.mitre.org/cve/search_cve_list.html'
1215
};

src/views/CVERecord/CVERecord.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,12 @@ export default {
9595
data() {
9696
return {
9797
isResultFromProd: false,
98-
// There is a special case when the website deals with some cached data. This ensures that the correct value is shown, even though it is not pretty
99-
resultUrl: this.GenericGlobalsStore.useSearch ? `https://${import.meta.env.VITE_CVE_SERVICES_BASE_URL}` : this.GenericGlobalsStore.cveServiceTestBaseUrl,
98+
// There is a special case when the website deals with some cached data.
99+
// This ensures that the correct value is shown, even though it is not
100+
// pretty
101+
resultUrl: this.GenericGlobalsStore.useSearch
102+
? this.GenericGlobalsStore.cveServicesBaseUrl
103+
: this.GenericGlobalsStore.cveServiceTestBaseUrl,
100104
usecveRecordStore: usecveRecordStore(),
101105
cveId: usecveRecordStore().cveId,
102106
errorMessageStore: useErrorMessageStore(),

src/views/CVERecord/SearchResults.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@
280280

281281
<script setup>
282282
import { useCveListSearchStore } from '@/stores/cveListSearch';
283+
import { useGenericGlobalsStore } from '@/stores/genericGlobals';
283284
import { usePartnerStore } from '@/stores/partners';
284285
import { computed, createApp, ref, watch } from 'vue';
285286
import { useRouter } from 'vue-router';
@@ -289,7 +290,7 @@ const cveListSearchStore = useCveListSearchStore();
289290
const partnerStore = usePartnerStore();
290291
const router = useRouter();
291292
const app = createApp({});
292-
const resultUrl = ref(`https://${import.meta.env.VITE_CVE_SERVICES_BASE_URL}`);
293+
const resultUrl = ref(useGenericGlobalsStore().cveServicesBaseUrl);
293294
294295
app.component('ServiceUnavailable', ServiceUnavailable);
295296

0 commit comments

Comments
 (0)