Skip to content

Commit a3f6901

Browse files
author
Nick Frasser
authored
Detect additional whitespace characters (#163)
* Detect additional whitespace characters Including non-breaking space. Fixes #162 * Avoid double export in options.js
1 parent 8d21838 commit a3f6901

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

src/linkify/core/scanner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const tlds = __TLDS__; // macro, see gulpfile.js
3939

4040
const NUMBERS = '0123456789'.split('');
4141
const ALPHANUM = '0123456789abcdefghijklmnopqrstuvwxyz'.split('');
42-
const WHITESPACE = [' ', '\f', '\r', '\t', '\v']; // excluding line breaks
42+
const WHITESPACE = [' ', '\f', '\r', '\t', '\v', '\u00a0', '\u1680', '\u180e']; // excluding line breaks
4343

4444
let domainStates = []; // states that jump to DOMAIN on /[a-z0-9]/
4545
let makeState = (tokenClass) => new State(tokenClass);

src/linkify/utils/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Options.prototype = {
9999
/**
100100
* Quick indexOf replacement for checking the ignoreTags option
101101
*/
102-
export function contains(arr, value) {
102+
function contains(arr, value) {
103103
for (var i = 0; i < arr.length; i++) {
104104
if (arr[i] === value) { return true; }
105105
}

test/spec/linkify/core/parser-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ var tests = [
151151
'Email with a underscore is [email protected] asd',
152152
[TEXT, EMAIL, TEXT],
153153
['Email with a underscore is ', '[email protected]', ' asd']
154+
], [
155+
'Url followed by nbsp: example.com/foo\u00a0bar',
156+
[TEXT, URL, TEXT],
157+
['Url followed by nbsp: ', 'example.com/foo', '\u00a0bar']
154158
]
155159
];
156160

test/spec/linkify/core/scanner-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const tests = [
6767
['-500px', [SYM, DOMAIN], ['-', '500px']],
6868
['500px-', [DOMAIN, SYM], ['500px', '-']],
6969
['123-456', [DOMAIN], ['123-456']],
70+
['foo\u00a0bar', [TLD, WS, TLD], ['foo', '\u00a0', 'bar']], // nbsp
7071
[
7172
'Direniş İzleme Grubu\'nun',
7273
[DOMAIN, SYM, WS, SYM, DOMAIN, WS, DOMAIN, SYM, DOMAIN],

0 commit comments

Comments
 (0)