From b8e63719f85299b1c4fbe431e8b2278118e2448f Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 4 Nov 2013 14:24:40 -0500 Subject: [PATCH] FIX: Don't autolink within a markdown link. --- .../javascripts/discourse/dialects/autolink_dialect.js | 4 ++++ test/javascripts/lib/markdown_test.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/app/assets/javascripts/discourse/dialects/autolink_dialect.js b/app/assets/javascripts/discourse/dialects/autolink_dialect.js index 85caabb70..f3c8c10e6 100644 --- a/app/assets/javascripts/discourse/dialects/autolink_dialect.js +++ b/app/assets/javascripts/discourse/dialects/autolink_dialect.js @@ -10,6 +10,10 @@ var urlReplacerArgs = { var url = matches[1], displayUrl = url; + + // Don't autolink a markdown link to something + if (url.match(/\]\[\d$/)) { return; } + // If we improperly caught a markdown link abort if (url.match(/\(http/)) { return; } diff --git a/test/javascripts/lib/markdown_test.js b/test/javascripts/lib/markdown_test.js index 70795be41..c5cdc6108 100644 --- a/test/javascripts/lib/markdown_test.js +++ b/test/javascripts/lib/markdown_test.js @@ -261,6 +261,12 @@ test("Oneboxing", function() { }); +test("links with full urls", function() { + cooked("[http://eviltrout.com][1] is a url\n\n[1]: http://eviltrout.com", + "

http://eviltrout.com is a url

", + "it supports links that are full URLs"); +}); + test("Code Blocks", function() { cooked("```\na\nb\nc\n\nd\n```",