From bfb5af68b48f0c7371066ff67e99ef53a29fb803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sat, 25 Jun 2016 14:40:24 +0200 Subject: [PATCH] Gist plugin: ignore trailing slashes and anchors Supersedes #783 --- js/plugins.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index 36f3430..be75934 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -435,11 +435,12 @@ plugins.factory('userPlugins', function() { // Embed GitHub gists var gistPlugin = new UrlPlugin('Gist', function(url) { - var regexp = /^https:\/\/gist\.github.com\/[^.?]+/i; + // ignore trailing slashes and anchors + var regexp = /^(https:\/\/gist\.github.com\/(?:.*?))[\/]?(?:\#.*)?$/i; var match = url.match(regexp); if (match) { // get the URL from the match to trim away pseudo file endings and request parameters - url = match[0] + '.json'; + url = match[1] + '.json'; // load gist asynchronously -- return a function here return function() { var element = this.getElement();