cfinke / Typo.js

A client-side JavaScript spellchecker that uses Hunspell-style dictionaries.
Other
501 stars 110 forks source link

`typo.suggest("ok")` throws `Cannot read properties of undefined (reading 'toLowerCase')` #82

Closed x4d3 closed 6 months ago

x4d3 commented 7 months ago

Using a french dictionnary, calling typo.suggest("ok") throws an error.

Stack:  TypeError: Cannot read properties of undefined (reading 'toLowerCase')
    at Typo.check (https://unpkg.com/typo-js@1.2.3/typo.js:656:42)
    at edits1 (https://unpkg.com/typo-js@1.2.3/typo.js:850:31)
    at correct (https://unpkg.com/typo-js@1.2.3/typo.js:937:14)
    at Typo.suggest (https://unpkg.com/typo-js@1.2.3/typo.js:1013:19)
    at HTMLDocument. (http://localhost:63343/typo-js-issues/index.html?_ijt=v2f2jgrhrvtbj3unin28nhpln:33:22)

Dictionary

https://github.com/x4d3/typo-js-issues/blob/main/fr_FR.aff https://github.com/x4d3/typo-js-issues/blob/main/fr_FR.dic

Issue is demonstrated here

https://github.com/x4d3/typo-js-issues/tree/main https://x4d3.github.io/typo-js-issues/

cfinke commented 6 months ago

I've pushed a fix for this to GitHub and NPM. Thanks for reporting it.