Language: TypeScript
Label: vulnerable
CWE: CWE-20 \u2014 Improper Input Validation
The product receives input or data, but it does
        not validate or incorrectly validates that the input has the
        properties that are required to process the data safely and
        correctly.

Code:
): ((query: string) => string[]) => {
  const languageIds = getLanguageIds(languages);
  const engine =
    searchEngine() ||
    new MiniSearch({
      fields: ["id"],
      searchOptions: {
        prefix: true
      }
    });

  if (!searchEngine()) {
    engine.addAll(languageIds);
    setSearchEngine(engine);
  }

  return (query: string) => {
    const suggestions = engine.autoSuggest(query, { prefix: true });

    return suggestions
      .filter((v) => v)
      .map(({ suggestion }) => {
        return suggestion;
      });
  };
};