diff --git a/src/libs/StringUtils.ts b/src/libs/StringUtils.ts index fffd54506fcb..5cc80a9a9005 100644 --- a/src/libs/StringUtils.ts +++ b/src/libs/StringUtils.ts @@ -81,23 +81,6 @@ function normalizeCRLF(value?: string): string | undefined { return value?.replace(/\r\n/g, '\n'); } -/** - * Generates an acronym for a string. - * @param string the string for which to produce the acronym - * @returns the acronym - */ -function getAcronym(string: string): string { - let acronym = ''; - const wordsInString = string.split(' '); - wordsInString.forEach((wordInString) => { - const splitByHyphenWords = wordInString.split('-'); - splitByHyphenWords.forEach((splitByHyphenWord) => { - acronym += splitByHyphenWord.substring(0, 1); - }); - }); - return acronym; -} - /** * Replace all line breaks with white spaces */ @@ -114,4 +97,4 @@ function getFirstLine(text = '') { return lines[0]; } -export default {sanitizeString, isEmptyString, removeInvisibleCharacters, normalizeAccents, normalizeCRLF, getAcronym, lineBreaksToSpaces, getFirstLine}; +export default {sanitizeString, isEmptyString, removeInvisibleCharacters, normalizeAccents, normalizeCRLF, lineBreaksToSpaces, getFirstLine}; diff --git a/src/libs/filterArrayByMatch.ts b/src/libs/filterArrayByMatch.ts index 3abf82b6afab..fc4c3e1e6a47 100644 --- a/src/libs/filterArrayByMatch.ts +++ b/src/libs/filterArrayByMatch.ts @@ -3,15 +3,13 @@ Use `threshold` option with one of the rankings defined below to control the strictness of the match. */ import type {ValueOf} from 'type-fest'; -import StringUtils from './StringUtils'; const MATCH_RANK = { - CASE_SENSITIVE_EQUAL: 7, - EQUAL: 6, - STARTS_WITH: 5, - WORD_STARTS_WITH: 4, - CONTAINS: 3, - ACRONYM: 2, + CASE_SENSITIVE_EQUAL: 6, + EQUAL: 5, + STARTS_WITH: 4, + WORD_STARTS_WITH: 3, + CONTAINS: 2, MATCHES: 1, NO_MATCH: 0, } as const; @@ -62,11 +60,6 @@ function getMatchRanking(testString: string, stringToRank: string): Ranking { return MATCH_RANK.NO_MATCH; } - // acronym - if (StringUtils.getAcronym(lowercaseTestString).includes(lowercaseStringToRank)) { - return MATCH_RANK.ACRONYM; - } - // will return a number between rankings.MATCHES and rankings.MATCHES + 1 depending on how close of a match it is. let matchingInOrderCharCount = 0; let charNumber = 0; diff --git a/tests/unit/StringUtilsTest.ts b/tests/unit/StringUtilsTest.ts deleted file mode 100644 index 04ce748c984b..000000000000 --- a/tests/unit/StringUtilsTest.ts +++ /dev/null @@ -1,20 +0,0 @@ -import StringUtils from '@libs/StringUtils'; - -describe('StringUtils', () => { - describe('getAcronym', () => { - it('should return the acronym of a string with multiple words', () => { - const acronym = StringUtils.getAcronym('Hello World'); - expect(acronym).toBe('HW'); - }); - - it('should return an acronym of a string with a single word', () => { - const acronym = StringUtils.getAcronym('Hello'); - expect(acronym).toBe('H'); - }); - - it('should return an acronym of a string when word in a string has a hyphen', () => { - const acronym = StringUtils.getAcronym('Hello Every-One'); - expect(acronym).toBe('HEO'); - }); - }); -});