Merge pull request #965 from tribut/pastebin-raw

Recognize /raw/ pastebin URLs
This commit is contained in:
Lorenz Hübschle-Schneider 2017-08-31 09:42:51 +02:00 committed by GitHub
commit 77d1c8925b
2 changed files with 3 additions and 2 deletions

View file

@ -473,10 +473,10 @@ plugins.factory('userPlugins', function() {
}); });
var pastebinPlugin = new UrlPlugin('Pastebin', function(url) { var pastebinPlugin = new UrlPlugin('Pastebin', function(url) {
var regexp = /^https?:\/\/pastebin\.com\/([^.?]+)/i; var regexp = /^https?:\/\/pastebin\.com\/(raw\/)?([^.?]+)/i;
var match = url.match(regexp); var match = url.match(regexp);
if (match) { if (match) {
var id = match[1], var id = match[2],
embedurl = "https://pastebin.com/embed_iframe/" + id, embedurl = "https://pastebin.com/embed_iframe/" + id,
element = angular.element('<iframe></iframe>') element = angular.element('<iframe></iframe>')
.attr('src', embedurl) .attr('src', embedurl)

View file

@ -146,6 +146,7 @@ describe('filter', function() {
it('should recognize pastebins', inject(function(plugins) { it('should recognize pastebins', inject(function(plugins) {
expectTheseMessagesToContain([ expectTheseMessagesToContain([
'http://pastebin.com/Wn3TetSE', 'http://pastebin.com/Wn3TetSE',
'http://pastebin.com/raw/Wn3TetSE',
], ],
'Pastebin', 'Pastebin',
plugins); plugins);