Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot call method 'replace' of INTEGER #47

Closed
mikhailkozlov opened this issue Sep 18, 2013 · 1 comment
Closed

TypeError: Cannot call method 'replace' of INTEGER #47

mikhailkozlov opened this issue Sep 18, 2013 · 1 comment

Comments

@mikhailkozlov
Copy link

Did not see the issue filed around number. Not sure even if it is valid use case, but tokenizer fails on indexing integer (like 10). I do not have much control into what is going into update even, so if sting got change to integer following code fails with TypeError.

lunr.tokenizer = function (str) {
if (!str) return []
if (Array.isArray(str)) return str.map(function (t) { return t.toLowerCase() })

var str = str.replace(/^\s+/, '')

Solved by simply adding empty string to the str variable before calling replace().

lunr.tokenizer = function (str) {
if (!str) return []
if (Array.isArray(str)) return str.map(function (t) { return t.toLowerCase() })

var str = str+'';
str = str.replace(/^\s+/, '')
@olivernn
Copy link
Owner

I've just pushed a new version, 0.4.2, that includes a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants