Skip to content

Commit f02ef4e

Browse files
author
Nick Frasser
authored
Single quotes should be treated as punctuation (#165)
Fixes #164
1 parent 836f7a7 commit f02ef4e

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/linkify/core/scanner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ S_START
6767
.on('}', makeState(CLOSEBRACE))
6868
.on(']', makeState(CLOSEBRACKET))
6969
.on(')', makeState(CLOSEPAREN))
70-
.on([',', ';', '!', '"'], makeState(PUNCTUATION));
70+
.on([',', ';', '!', '"', '\''], makeState(PUNCTUATION));
7171

7272
// Whitespace jumps
7373
// Tokens of only non-newline whitespace are arbitrarily long

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ var tests = [
155155
'Url followed by nbsp: example.com/foo\u00a0bar',
156156
[TEXT, URL, TEXT],
157157
['Url followed by nbsp: ', 'example.com/foo', '\u00a0bar']
158+
], [
159+
'A link in \'singlequote.club/wat\' extra fluff at the end',
160+
[TEXT, URL, TEXT],
161+
['A link in \'', 'singlequote.club/wat', '\' extra fluff at the end']
158162
]
159163
];
160164

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const tests = [
4141
['&', [SYM], ['&']],
4242
['&?<>(', [SYM, QUERY, SYM, SYM, OPENPAREN], ['&', '?', '<', '>', '(']],
4343
['([{}])', [OPENPAREN, OPENBRACKET, OPENBRACE, CLOSEBRACE, CLOSEBRACKET, CLOSEPAREN], ['(', '[', '{', '}', ']', ')']],
44-
['!,;', [PUNCTUATION, PUNCTUATION, PUNCTUATION], ['!', ',', ';']],
44+
['!,;\'', [PUNCTUATION, PUNCTUATION, PUNCTUATION, PUNCTUATION], ['!', ',', ';', '\'']],
4545
['hello', [DOMAIN], ['hello']],
4646
['Hello123', [DOMAIN], ['Hello123']],
4747
['hello123world', [DOMAIN], ['hello123world']],
@@ -70,7 +70,7 @@ const tests = [
7070
['foo\u00a0bar', [TLD, WS, TLD], ['foo', '\u00a0', 'bar']], // nbsp
7171
[
7272
'Direniş İzleme Grubu\'nun',
73-
[DOMAIN, SYM, WS, SYM, DOMAIN, WS, DOMAIN, SYM, DOMAIN],
73+
[DOMAIN, SYM, WS, SYM, DOMAIN, WS, DOMAIN, PUNCTUATION, DOMAIN],
7474
['Direni', 'ş', ' ', 'İ', 'zleme', ' ', 'Grubu', '\'', 'nun']
7575
]
7676
];

0 commit comments

Comments
 (0)