From beaa3426dd929df1c6a08b9cce05dbf4def25b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sun, 8 Feb 2015 11:17:06 +0100 Subject: [PATCH] Rewrite vine plugin with urlPlugin --- js/plugins.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index 1d971cd..0b3211e 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -400,22 +400,17 @@ plugins.factory('userPlugins', function() { /* * Vine plugin */ - var vinePlugin = new Plugin(function(message) { - - var regexp = /https?:\/\/(www\.)?vine.co\/v\/([a-zA-Z0-9]+)(\/.*)?/g; - var content = []; - var match; - - // Iterate over all matches - while ((match = regexp.exec(message)) !== null) { - var id = match[2]; - var embedurl = "https://vine.co/v/" + id + "/embed/simple?audio=1"; - content.push(''); - } - - return content; - }); - vinePlugin.name = "Vine"; + var vinePlugin = new Plugin( + urlPlugin(function (url) { + var regexp = /^https?:\/\/(www\.)?vine.co\/v\/([a-zA-Z0-9]+)(\/.*)?/i, + match = url.match(regexp); + if (match) { + var id = match[2], embedurl = "https://vine.co/v/" + id + "/embed/simple?audio=1"; + return ''; + } + }) + ); + vinePlugin.name = 'Vine'; return { plugins: [youtubePlugin, dailymotionPlugin, allocinePlugin, imagePlugin, spotifyPlugin, cloudmusicPlugin, googlemapPlugin, asciinemaPlugin, yrPlugin, gistPlugin, tweetPlugin, vinePlugin]