INNER CODE UNIT · JavaScript

initializeSearchService

mitre-attack/attack-website · attack-search/src/index.js:127

async function initializeSearchService() {
  console.debug('Initializing search service...');
  searchParsingIcon.show();

  const saved_uuid = localStorage.getItem(searchCacheKey);
  const cachedBuildId = `${build_uuid}-search-${searchCacheVersion}`;
  console.debug(`Retrieved the saved_uuid from localStorage: ${saved_uuid}`);

  // Check if the browser supports IndexedDB. Search service can only work in environments that support IndexedDB.
  if ('indexedDB' in window) {
    // Verify if the buildUUID is already cached in LocalStorage. This check is performed to determine if the search
    // service has been initialized. Each website build instance possesses a unique buildUUID, preventing different
    // website builds from sharing the same search index.
    if (saved_uuid && saved_uuid === cachedBuildId) {
      // Restore search service from IndexedDB
      try {
        console.debug('Initializing SearchService (assume documents already cached)...');
        searchService = new SearchService('search-results', saved_uuid);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…