From 015e3917ac1fafa73bc3298ec7ae4e2dd9ff5b80 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 30 May 2024 10:07:58 -0700 Subject: [PATCH] common: Fix TypeScript noUncheckedIndexedAccess errors. Signed-off-by: Anders Kaseorg --- web/src/common.ts | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/web/src/common.ts b/web/src/common.ts index 1df24fea16..ade48f1219 100644 --- a/web/src/common.ts +++ b/web/src/common.ts @@ -7,21 +7,7 @@ export const status_classes = "alert-error alert-success alert-info alert-warnin export function phrase_match(query: string, phrase: string): boolean { // match "tes" to "test" and "stream test" but not "hostess" - let i; - query = query.toLowerCase(); - - phrase = phrase.toLowerCase(); - if (phrase.startsWith(query)) { - return true; - } - - const parts = phrase.split(" "); - for (i = 0; i < parts.length; i += 1) { - if (parts[i].startsWith(query)) { - return true; - } - } - return false; + return (" " + phrase.toLowerCase()).includes(" " + query.toLowerCase()); } const keys_map = new Map([