the-abe-train / globle

Use your geography knowledge to figure out the mystery country in as few guesses as possbile!
https://globle-game.com
Other
185 stars 78 forks source link

Extra spaces in names counts as a misspelling #122

Open owenstone opened 2 years ago

owenstone commented 2 years ago

Seems a bit harsh that an extra space between words fails to be recognized. Example: "Saint Vincent and the Grenadines" (with two spaces between the words "Vincent" & "and" wasn't recognized and produced the "Invalid guess" response.

Expected: Extra whitespace where some whitespace is expected should be recognized as a valid entry.

owenstone commented 2 years ago

I tested this fix:

--- a/src/components/Guesser.tsx
+++ b/src/components/Guesser.tsx
@@ -53,7 +53,7 @@ export default function Guesser({
   // Check territories function
   function runChecks() {
     const trimmedName = guessName
-      .trim()
+      .replace(/\s+/g,' ').trim()
       .toLowerCase()
       .replace(/&/g, "and")
       .replace(/^st\s/g, "st. ");