Comparing version 1.9.1 to 1.10.0
@@ -94,2 +94,5 @@ var Mehdown; | ||
text = text.replace(/<a href="(https?:\/\/(?:www\.)reddit\.com\/.*)">https?:\/\/(?:www\.)reddit\.com\/.*<\/a>/gi, Mehdown.reddit); | ||
// Images | ||
@@ -116,3 +119,3 @@ var imgRegExp = /<a href="(https?:\/\/[-\w%\/\.]+\.(?:jpg|jpeg|gif|png)(?:\?[-\+=&;%@\.\w]+)?)">\1<\/a>/gi; | ||
// Find href attribute | ||
for(var i = 0; i < attributes.length; i++) { | ||
for (var i = 0; i < attributes.length; i++) { | ||
if(attributes[i].indexOf('href=') === 0) { | ||
@@ -126,3 +129,3 @@ href = attributes[i]; | ||
if(href.indexOf('href="/') === 0 || href.indexOf(localDomain) === 0) { | ||
if (href.indexOf('href="/') === 0 || href.indexOf(localDomain) === 0) { | ||
isLocal = true; | ||
@@ -137,3 +140,3 @@ } | ||
if(!isLocal) { | ||
if (!isLocal) { | ||
anchor = '<a rel="nofollow" target="_blank"' + anchor.substr(2); | ||
@@ -195,2 +198,9 @@ } | ||
Mehdown.reddit = function(match, url) { | ||
var html = '<div class="reddit-embed" data-embed-media="www.redditmedia.com" data-embed-live="true"><a href="' + url + '">' + url + '</a></div>'; | ||
html += '<script async src="https://www.redditstatic.com/comment-embed.js"></script>'; | ||
return html; | ||
}; | ||
Mehdown.vine = function(videoId) { | ||
@@ -197,0 +207,0 @@ return '<iframe allowfullscreen class="vine" frameborder="0" src="//vine.co/v/' + videoId + '/embed/simple"></iframe>'; |
@@ -13,3 +13,3 @@ { | ||
}, | ||
"version": "1.9.1" | ||
"version": "1.10.0" | ||
} |
@@ -193,2 +193,9 @@ var assert = require('assert'); | ||
describe('Reddit URLs', function() { | ||
it('https://www.reddit.com/r/ProgrammerHumor/comments/30lhaf/mehcom_api_url_poking_at_steve_balmer/cptizym', function() { | ||
var text = mehdown.parse('<p><a href="https://www.reddit.com/r/ProgrammerHumor/comments/30lhaf/mehcom_api_url_poking_at_steve_balmer/cptizym">https://www.reddit.com/r/ProgrammerHumor/comments/30lhaf/mehcom_api_url_poking_at_steve_balmer/cptizym</a></p>'); | ||
assert.equal(text, '<p><div class="reddit-embed" data-embed-media="www.redditmedia.com" data-embed-live="true"><a rel="nofollow" target="_blank" href="https://www.reddit.com/r/ProgrammerHumor/comments/30lhaf/mehcom_api_url_poking_at_steve_balmer/cptizym">https://www.reddit.com/r/ProgrammerHumor/comments/30lhaf/mehcom_api_url_poking_at_steve_balmer/cptizym</a></div><script async src="https://www.redditstatic.com/comment-embed.js"></script></p>'); | ||
}); | ||
}); | ||
describe('Twitter Status URLs', function() { | ||
@@ -195,0 +202,0 @@ it('https://twitter.com/mediocrelabs/status/410516133955907584', function() { |
Sorry, the diff of this file is not supported yet
37389
379