Gist plugin: ignore trailing slashes and anchors

Supersedes #783
This commit is contained in:
Lorenz Hübschle-Schneider 2016-06-25 14:40:24 +02:00 committed by GitHub
parent a3a05983fc
commit bfb5af68b4
1 changed files with 3 additions and 2 deletions

View File

@ -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();