Skip to content

Commit

Permalink
Add tests for invalid urls
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Oct 6, 2017
1 parent 530d717 commit 586a486
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/client/js/libs/handlebars/ircmessageparser/findLinks.js
Expand Up @@ -103,4 +103,49 @@ describe("findLinks", () => {

expect(actual).to.deep.equal(expected);
});

it("does not find invalid urls", () => {
const input = "www.example.com ssh://-oProxyCommand=whois"; // Issue #1412
const expected = [{
start: 0,
end: 15,
link: "http://www.example.com"
}, {
end: 42,
start: 16,
link: "ssh://-oProxyCommand=whois"
}];

const actual = findLinks(input);

expect(actual).to.deep.equal(expected);

const input2 = "www.example.com http://root:'some%pass'@hostname/database"; // Issue #1618
const expected2 = [{
start: 0,
end: 15,
link: "http://www.example.com"
}];

const actual2 = findLinks(input2);

expect(actual2).to.deep.equal(expected2);
});

it("keeps parsing after finding an invalid url", () => {
const input = "www.example.com http://a:%p@c http://thelounge.chat";
const expected = [{
start: 0,
end: 15,
link: "http://www.example.com"
}, {
start: 30,
end: 51,
link: "http://thelounge.chat"
}];

const actual = findLinks(input);

expect(actual).to.deep.equal(expected);
});
});

0 comments on commit 586a486

Please sign in to comment.