From 1b6ba78acd80b0e9153b2a610328aceb161ceb37 Mon Sep 17 00:00:00 2001 From: Felix Eckhofer Date: Wed, 30 Aug 2017 19:05:36 +0200 Subject: [PATCH] Recognize /raw/ pastebin URLs --- js/plugins.js | 4 ++-- test/unit/plugins.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index 2140d3f..01ab40c 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -473,10 +473,10 @@ plugins.factory('userPlugins', function() { }); 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); if (match) { - var id = match[1], + var id = match[2], embedurl = "https://pastebin.com/embed_iframe/" + id, element = angular.element('') .attr('src', embedurl) diff --git a/test/unit/plugins.js b/test/unit/plugins.js index c723a7e..eaec98b 100644 --- a/test/unit/plugins.js +++ b/test/unit/plugins.js @@ -146,6 +146,7 @@ describe('filter', function() { it('should recognize pastebins', inject(function(plugins) { expectTheseMessagesToContain([ 'http://pastebin.com/Wn3TetSE', + 'http://pastebin.com/raw/Wn3TetSE', ], 'Pastebin', plugins);