From 7d2952049f731eb262bc4b7b68bbca832fa25809 Mon Sep 17 00:00:00 2001 From: Elbert Alias Date: Mon, 13 Mar 2017 09:36:32 +1100 Subject: [PATCH] Fix slugify function --- src/drivers/chrome/js/popup.js | 2 +- src/drivers/firefox/data/js/panel.js | 2 +- src/drivers/webextension/js/popup.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/drivers/chrome/js/popup.js b/src/drivers/chrome/js/popup.js index b7c4d68d3..a2657b67b 100644 --- a/src/drivers/chrome/js/popup.js +++ b/src/drivers/chrome/js/popup.js @@ -5,7 +5,7 @@ document.addEventListener('DOMContentLoaded', function() { detectedApps = d.getElementById('detected-apps'); slugify = function(string) { - return string.toLowerCase().replace(/ /g, '-').replace(/[^\w-]/g, ''); + return string.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/--+/g, '-').replace(/(?:^-|-$)/, ''); }; popup = { diff --git a/src/drivers/firefox/data/js/panel.js b/src/drivers/firefox/data/js/panel.js index 5a01f91ef..60f97d102 100644 --- a/src/drivers/firefox/data/js/panel.js +++ b/src/drivers/firefox/data/js/panel.js @@ -7,7 +7,7 @@ empty = d.getElementById('empty'); slugify = function(string) { - return string.toLowerCase().replace(/ /g, '-').replace(/[^\w-]/g, ''); + return string.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/--+/g, '-').replace(/(?:^-|-$)/g, ''); }; while ( detectedApps.firstChild ) { diff --git a/src/drivers/webextension/js/popup.js b/src/drivers/webextension/js/popup.js index 2b0a0e84d..a5dd2cb61 100644 --- a/src/drivers/webextension/js/popup.js +++ b/src/drivers/webextension/js/popup.js @@ -5,7 +5,7 @@ document.addEventListener('DOMContentLoaded', function() { detectedApps = d.getElementById('detected-apps'); slugify = function(string) { - return string.toLowerCase().replace(/ /g, '-').replace(/[^\w-]/g, ''); + return string.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/--+/g, '-').replace(/(?:^-|-$)/, ''); }; popup = {