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

Split on hyphens as well as whitespace #98

Merged
merged 1 commit into from
Jul 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ lunr.tokenizer = function (obj) {
}

return str
.split(/\s+/)
.split(/(?:\s+|\-)/)
.map(function (token) {
return token.toLowerCase()
})
Expand Down
6 changes: 6 additions & 0 deletions test/tokenizer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ test('calling to string on passed val', function () {
deepEqual(lunr.tokenizer(date).slice(0, 4), ['tue', 'jan', '01', '2013'])
})

test("splitting strings with hyphens", function () {
var simpleString = "take the New York-San Francisco flight",
tokens = lunr.tokenizer(simpleString)

deepEqual(tokens, ['take', 'the', 'new', 'york', 'san', 'francisco', 'flight'])
})