Fuse: Token Seperation Issue

Created on 23 Jan 2017  路  7Comments  路  Source: krisk/Fuse

I have discovered an issue when tokenize and matchAllTokens is enabled. When you search for white (with a trailing whitespace), the tokens are ['white', '']. This causes fuse to return no results due to one empty token. Would removing empty tokens as below be a fix for this?

var tokens = pattern.split(options.tokenSeparator).filter(function(token){
    return token !== '';
})
Stale bug

Most helpful comment

I solved this by using String.prototype.trim() on my search query to remove unwanted leading /trailing whitespace.

fuse.search(query.trim());

All 7 comments

Good find. Ideally, white spaces should be eliminated. Any takers? 馃槃

I have applied a simple fix for this issue. Passes all tests and works as expected.

@krisk Can we re-build @jwmann's PR?

@jeffal I pulled in and re-built with the most recent master changes. Thank god Travis-CI didn't fall off a cliff this time and built successfully.

Just needs a merge.

Can the PR be opened and merged? Seems like a simple fix no? ^^

I solved this by using String.prototype.trim() on my search query to remove unwanted leading /trailing whitespace.

fuse.search(query.trim());

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

Was this page helpful?
0 / 5 - 0 ratings