diff --git a/packages/linkifyjs/src/parser.js b/packages/linkifyjs/src/parser.js
index f8b9d742..e1354070 100644
--- a/packages/linkifyjs/src/parser.js
+++ b/packages/linkifyjs/src/parser.js
@@ -81,7 +81,6 @@ export function init({ groups }) {
tk.DOLLAR,
tk.EQUALS,
tk.HYPHEN,
- tk.NUM,
tk.OPENBRACE,
tk.PERCENT,
tk.PIPE,
@@ -184,11 +183,11 @@ export function init({ groups }) {
tt(DomainDotTldColonPort, tk.SLASH, Url);
// Note that domains that begin with schemes are treated slighly differently
- const UriPrefix = tt(Scheme, tk.COLON); // e.g., 'mailto:' or 'http://'
+ const SchemeColon = tt(Scheme, tk.COLON); // e.g., 'mailto:'
const SlashSchemeColon = tt(SlashScheme, tk.COLON); // e.g., 'http:'
const SlashSchemeColonSlash = tt(SlashSchemeColon, tk.SLASH); // e.g., 'http:/'
- tt(SlashSchemeColonSlash, tk.SLASH, UriPrefix);
+ const UriPrefix = tt(SlashSchemeColonSlash, tk.SLASH); // e.g., 'http://'
// Scheme states can transition to domain states
ta(Scheme, groups.domain, Domain);
@@ -199,7 +198,10 @@ export function init({ groups }) {
tt(SlashScheme, tk.HYPHEN, DomainHyphen);
// Force URL with scheme prefix followed by anything sane
+ ta(SchemeColon, groups.domain, Url);
+ tt(SchemeColon, tk.SLASH, Url);
ta(UriPrefix, groups.domain, Url);
+ ta(UriPrefix, qsAccepting, Url);
tt(UriPrefix, tk.SLASH, Url);
// URL, followed by an opening bracket
diff --git a/test/spec/html/email.html b/test/spec/html/email.html
new file mode 100644
index 00000000..781b5735
--- /dev/null
+++ b/test/spec/html/email.html
@@ -0,0 +1,36 @@
+
+
+
+
+
diff --git a/test/spec/html/options.js b/test/spec/html/options.js
index 82644223..0862616d 100644
--- a/test/spec/html/options.js
+++ b/test/spec/html/options.js
@@ -17,6 +17,7 @@ export default {
.split('\n'),
extra: fs.readFileSync(__dirname + '/extra.html', 'utf8').trim(), // for jQuery plugin tests
+ email: fs.readFileSync(__dirname + '/email.html', 'utf8').trim(), // for linkify-html performance tests
altOptions: {
className: 'linkified',
rel: 'nofollow',
diff --git a/test/spec/linkify-html.test.js b/test/spec/linkify-html.test.js
index d3011e42..d14afd36 100644
--- a/test/spec/linkify-html.test.js
+++ b/test/spec/linkify-html.test.js
@@ -199,4 +199,8 @@ describe('linkify-html', () => {
const input = '這禮拜是我們新的循環 (3/23-4/19), 我將於這週日給 Jeffrey 補課,並且我們會在這期間選另外一個可以上課的日期。';
expect(linkifyHtml(input)).to.be.ok;
});
+
+ it('Handles complex email page', () => {
+ expect(linkifyHtml(htmlOptions.email)).to.be.ok;
+ });
});
diff --git a/test/spec/linkifyjs/parser.test.js b/test/spec/linkifyjs/parser.test.js
index 3a91aef9..ee12d756 100644
--- a/test/spec/linkifyjs/parser.test.js
+++ b/test/spec/linkifyjs/parser.test.js
@@ -220,6 +220,10 @@ const tests = [
'~@example.org',
[Email],
['~@example.org']
+ ], [
+ '~emersion/soju-dev@lists.sr.ht',
+ [Email],
+ ['~emersion/soju-dev@lists.sr.ht']
], [
'test@example2.com',
[Email],
@@ -228,10 +232,6 @@ const tests = [
'noreply@500px.so',
[Email],
['noreply@500px.so']
- ], [
- '~emersion/soju-dev@lists.sr.ht',
- [Email],
- ['~emersion/soju-dev@lists.sr.ht']
], [
'http@example.com',
[Email],
@@ -264,7 +264,15 @@ const tests = [
'Hello\nWorld',
[Text, Nl, Text],
['Hello', '\n', 'World'],
- ]
+ ], [
+ 'And http://↑↑↓↓←→←→ba.tk/ is also a URL',
+ [Text, Url, Text],
+ ['And ', 'http://↑↑↓↓←→←→ba.tk/', ' is also a URL']
+ ], [
+ 'This Url www.drive1.com with www and digits also www.500px.com',
+ [Text, Url, Text, Url],
+ ['This Url ', 'www.drive1.com', ' with www and digits also ', 'www.500px.com']
+ ],
];