From 38edd713e487b59286740b28c227fb66f54666be Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 20 Apr 2016 16:21:50 -0700 Subject: [PATCH] Ensure punctuation is not treated as words. [closes #2268] --- lodash.js | 4 ++-- test/test.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lodash.js b/lodash.js index 35b169c51..cd1d23dab 100644 --- a/lodash.js +++ b/lodash.js @@ -180,11 +180,11 @@ rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', - rsQuoteRange = '\\u2018\\u2019\\u201c\\u201d', + rsPunctuationRange = '\\u2000-\\u206f', rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', rsVarRange = '\\ufe0e\\ufe0f', - rsBreakRange = rsMathOpRange + rsNonCharRange + rsQuoteRange + rsSpaceRange; + rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; /** Used to compose unicode capture groups. */ var rsApos = "['\u2019]", diff --git a/test/test.js b/test/test.js index 1e85f794a..b30f86701 100644 --- a/test/test.js +++ b/test/test.js @@ -24685,6 +24685,21 @@ assert.deepEqual(actual, expected); }); + QUnit.test('should not treat punctuation as words', function(assert) { + assert.expect(1); + + var marks = [ + '\u2012', '\u2013', '\u2014', '\u2015', + '\u2024', '\u2025', '\u2026', + '\u205d', '\u205e' + ]; + + var expected = lodashStable.map(marks, alwaysEmptyArray), + actual = lodashStable.map(marks, _.words); + + assert.deepEqual(actual, expected); + }); + QUnit.test('should support a `pattern` argument', function(assert) { assert.expect(2);