Merge pull request #2543 from thelounge/xpaw/link-title
Fix multiple <title> tags being concatenated
This commit is contained in:
commit
32ccfd50af
@ -86,7 +86,7 @@ function parseHtml(preview, res, client) {
|
|||||||
preview.type = "link";
|
preview.type = "link";
|
||||||
preview.head =
|
preview.head =
|
||||||
$('meta[property="og:title"]').attr("content")
|
$('meta[property="og:title"]').attr("content")
|
||||||
|| $("title").text()
|
|| $("head > title, title").first().text()
|
||||||
|| "";
|
|| "";
|
||||||
preview.body =
|
preview.body =
|
||||||
$('meta[property="og:description"]').attr("content")
|
$('meta[property="og:description"]').attr("content")
|
||||||
|
@ -72,7 +72,25 @@ describe("Link plugin", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.irc.once("msg:preview", function(data) {
|
this.irc.once("msg:preview", function(data) {
|
||||||
expect(data.preview.head, "opengraph test");
|
expect(data.preview.head).to.equal("opengraph test");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should find only the first matching tag", function(done) {
|
||||||
|
const message = this.irc.createMessage({
|
||||||
|
text: "http://localhost:9002/duplicate-tags",
|
||||||
|
});
|
||||||
|
|
||||||
|
link(this.irc, this.network.channels[0], message);
|
||||||
|
|
||||||
|
app.get("/duplicate-tags", function(req, res) {
|
||||||
|
res.send("<title>test</title><title>magnifying glass icon</title><meta name='description' content='desc1'><meta name='description' content='desc2'>");
|
||||||
|
});
|
||||||
|
|
||||||
|
this.irc.once("msg:preview", function(data) {
|
||||||
|
expect(data.preview.head).to.equal("test");
|
||||||
|
expect(data.preview.body).to.equal("desc1");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user