explicit autolink should not be oneboxed

This commit is contained in:
Sam 2017-06-27 15:34:16 -04:00
parent 91a91d57f0
commit 232de90607
2 changed files with 3 additions and 2 deletions

View File

@ -17,7 +17,7 @@ function applyOnebox(state, silent) {
for(j=0;j<token.children.length;j++){ for(j=0;j<token.children.length;j++){
let child = token.children[j]; let child = token.children[j];
if (child.type === "link_open") { if (child.type === "link_open" && child.markup === 'linkify' && child.info === 'auto') {
// look behind for soft or hard break // look behind for soft or hard break
if (j > 0 && token.children[j-1].tag !== 'br') { if (j > 0 && token.children[j-1].tag !== 'br') {

View File

@ -312,7 +312,7 @@ HTML
expect(PrettyText.excerpt(emoji_code, 100)).to eq(":heart:") expect(PrettyText.excerpt(emoji_code, 100)).to eq(":heart:")
end end
context 'option ot preserve onebox source' do context 'option to preserve onebox source' do
it "should return the right excerpt" do it "should return the right excerpt" do
onebox = "<aside class=\"onebox whitelistedgeneric\">\n <header class=\"source\">\n <a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">meta.discourse.org</a>\n </header>\n <article class=\"onebox-body\">\n <img src=\"https://cdn-enterprise.discourse.org/meta/user_avatar/meta.discourse.org/gerhard/200/70381_1.png\" width=\"\" height=\"\" class=\"thumbnail\">\n\n<h3><a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">Infrequent translation updates in stable branch</a></h3>\n\n<p>Well, there's an Italian translation for \"New Topic\" in beta, it's been there since November 2014 and it works here on meta. Do you have any plugins installed? Try disabling them. I'm quite confident that it's either a plugin or a site...</p>\n\n </article>\n <div class=\"onebox-metadata\">\n \n \n </div>\n <div style=\"clear: both\"></div>\n</aside>\n\n\n" onebox = "<aside class=\"onebox whitelistedgeneric\">\n <header class=\"source\">\n <a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">meta.discourse.org</a>\n </header>\n <article class=\"onebox-body\">\n <img src=\"https://cdn-enterprise.discourse.org/meta/user_avatar/meta.discourse.org/gerhard/200/70381_1.png\" width=\"\" height=\"\" class=\"thumbnail\">\n\n<h3><a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">Infrequent translation updates in stable branch</a></h3>\n\n<p>Well, there's an Italian translation for \"New Topic\" in beta, it's been there since November 2014 and it works here on meta. Do you have any plugins installed? Try disabling them. I'm quite confident that it's either a plugin or a site...</p>\n\n </article>\n <div class=\"onebox-metadata\">\n \n \n </div>\n <div style=\"clear: both\"></div>\n</aside>\n\n\n"
expected = "<a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">meta.discourse.org</a>" expected = "<a href=\"https://meta.discourse.org/t/infrequent-translation-updates-in-stable-branch/31213/9\">meta.discourse.org</a>"
@ -629,6 +629,7 @@ HTML
expect(PrettyText.cook("http://a.com ")).to include('onebox') expect(PrettyText.cook("http://a.com ")).to include('onebox')
expect(PrettyText.cook("http://a.com a")).not_to include('onebox') expect(PrettyText.cook("http://a.com a")).not_to include('onebox')
expect(PrettyText.cook("- http://a.com")).not_to include('onebox') expect(PrettyText.cook("- http://a.com")).not_to include('onebox')
expect(PrettyText.cook("<http://a.com>")).not_to include('onebox')
end end
it "can handle bbcode" do it "can handle bbcode" do