From 8e1e87141147d601d6c7d0c367eef7d9fbe2f2c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 14 Jul 2014 23:17:22 +0100 Subject: [PATCH] Fix matching (#segments) --- js/plugins.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index db21075..eba813d 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -292,14 +292,13 @@ plugins.factory('userPlugins', function() { if (match) { var url = match[0]; - var regexp = /^https?:\/\/(?:www\.)?yr\.no\/(place|stad|sted|sadji)\/([^\s.;,(){}<>\/]+)\/([^\s.;,(){}<>\/]+)\/([^\s.;,(){}<>\/]+)/; + var regexp = /^https?:\/\/(?:www\.)?yr\.no\/(place|stad|sted|sadji|paikka)\/(([^\s.;,(){}<>\/]+\/){3,})/; match = url.match(regexp); if (match) { var language = match[1]; - var country = match[2]; - var province = match[3]; - var city = match[4]; - url = "http://www.yr.no/" + language + "/" + country + "/" + province + "/" + city + "/avansert_meteogram.png"; + var location = match[2]; + var city = match[match.length - 1].slice(0, -1); + url = "http://www.yr.no/" + language + "/" + location + "avansert_meteogram.png"; return "Meteogram for " + city + ""; } }