File size: 513 Bytes
f24ad59
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { BasicSearchResult } from "../v1/search/types"

export function parseBasicSearchResult(input?: any, defaultResults: BasicSearchResult[] = []): BasicSearchResult[] {
  let basicResults: BasicSearchResult[] = defaultResults
  try {
    const rawString = decodeURIComponent(`${input || ""}` || "").trim() as string
    const maybeExistingResults = JSON.parse(rawString)
    if (Array.isArray(maybeExistingResults)) {
      basicResults = maybeExistingResults
    }
  } catch (err) {}
  return basicResults
}