Skip to content
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: 2 additions & 0 deletions packages/linkifyjs/src/parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function init({ groups }) {
tk.COMMA,
tk.DOT,
tk.EXCLAMATION,
tk.PERCENT,
tk.QUERY,
tk.QUOTE,
tk.SEMI,
Expand Down Expand Up @@ -211,6 +212,7 @@ export function init({ groups }) {
// Force URL with scheme prefix followed by anything sane
ta(SchemeColon, groups.domain, Url);
tt(SchemeColon, tk.SLASH, Url);
tt(SchemeColon, tk.QUERY, Url);
ta(UriPrefix, groups.domain, Url);
ta(UriPrefix, qsAccepting, Url);
tt(UriPrefix, tk.SLASH, Url);
Expand Down
9 changes: 8 additions & 1 deletion test/spec/linkifyjs.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ describe('linkifyjs', () => {

describe('registerCustomProtocol', () => {
beforeEach(() => {
linkify.registerCustomProtocol('instagram', true);
linkify.registerCustomProtocol('view-source');
linkify.registerCustomProtocol('instagram', true);
linkify.registerCustomProtocol('magnet', true);
});

it('Detects basic protocol', () => {
Expand All @@ -49,6 +50,12 @@ describe('linkifyjs', () => {
expect(linkify.test('instagram://user/nfrasser', 'url')).to.be.ok;
});

it('Detects magnet protocol', () => {
const magnetLink =
'magnet:?xt=urn:btih:5a7f5e0f3ce439e2f1a83e718a8405ec8809110b&dn=ernfkjenrkfk%5FSQ80%5FV%5Fv1.0.0%5Ferfnkerkf%5Ferfnkerkfefrfvegrteggt.net.rar';
expect(linkify.test(magnetLink, 'url')).to.be.ok;
});

it('Detects compound protocol', () => {
expect(linkify.test('view-source://http://github.com/', 'url')).to.be.ok;
});
Expand Down
Loading