Skip to content

Commit 5285d7d

Browse files
Fix toSearchable to not strip mid-string "the" (completes #460)
PR #460 fixed the backend's to_searchable() (search/sanitisation.py) so it no longer strips the word "the" from the middle of card names (issue #435), but the frontend's hand-maintained mirror of that logic in processing.ts was never updated to match, so it still mangled names like "Adanto, the First Fort" into "adanto first fort" instead of the correct "adanto the first fort". Removes the same two lines #460 removed from the backend, and updates the test case that was asserting the buggy output. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 3c717d2 commit 5285d7d

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎frontend/src/common/processing.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,10 @@ describe("toSearchable", () => {
501501
test.each([
502502
{ input: "Lightning Bolt", expectedOutput: "lightning bolt" },
503503
{ input: " Lightning BOLT ", expectedOutput: "lightning bolt" },
504-
{ input: "Adanto, the First Fort", expectedOutput: "adanto first fort" },
504+
{
505+
input: "Adanto, the First Fort",
506+
expectedOutput: "adanto the first fort",
507+
},
505508
{ input: "Black Lotus (Masterpiece)", expectedOutput: "black lotus" }, // brackets removal
506509
{
507510
input: "Black Lotus (Masterpiece, But With Punctuation! )",

‎frontend/src/common/processing.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,9 @@ export const toSearchable = (inputString: string): string =>
389389
.toLowerCase()
390390
.replaceAll(/[\(\[].*?[\)\]]/g, "")
391391
.replace("-", " ")
392-
.replace(" the ", " ")
393392
.replace("’", "'")
394393
.replaceAll(/[!"#\$%&'\(\)\*\+,-\.\/:;<=>\?@\[\]\^_`{\|}~\/]/g, "") // remove punctuation
395394
.replaceAll(/[0123456789]/g, "") // remove digits
396-
.replaceAll(/^the (.*$)/g, "$1") // remove "the " at start of string
397395
// remove accents - match elasticsearch `asciifolding` filter. https://stackoverflow.com/a/37511463/13021511
398396
.normalize("NFD")
399397
.replace(/\p{Diacritic}/gu, "")

0 commit comments

Comments
 (0)