From 336510d90ccdb7838ad286bdf2b2c7c6fb594f90 Mon Sep 17 00:00:00 2001 From: "s.sharov" Date: Tue, 20 Dec 2016 15:58:10 +0300 Subject: [PATCH 1/3] Refactoring: move exclude extensions to array and map it with regexp (much more clean to read the code) --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 23eab8b..3241fec 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,10 @@ module.exports = function livereload(opt) { // options opt = opt || {}; - var ignore = opt.ignore || opt.excludeList || [/\.js(\?.*)?$/, /\.css(\?.*)?$/, /\.svg(\?.*)?$/, /\.ico(\?.*)?$/, - /\.woff(\?.*)?$/, /\.png(\?.*)?$/, /\.jpg(\?.*)?$/, /\.jpeg(\?.*)?$/, /\.gif(\?.*)?$/, /\.pdf(\?.*)?$/, - /\.json(\?.*)?$/ - ]; + var excludeExtensions = ['js', 'css', 'svg', 'ico', 'woff', 'png', 'jpg', 'jpeg', 'gif', 'pdf', 'json']; + var ignore = opt.ignore || opt.excludeList || excludeExtensions.map(function (ext) { + return new RegExp('\\.' + ext + '(\\?.*)?$'); + }); var include = opt.include || [/.*/]; var html = opt.html || _html; From b3861ebb943f8d1445f8d91c843a8991633275be Mon Sep 17 00:00:00 2001 From: "s.sharov" Date: Tue, 20 Dec 2016 15:59:21 +0300 Subject: [PATCH 2/3] Added archive extensions to exclude --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3241fec..4931034 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ module.exports = function livereload(opt) { // options opt = opt || {}; - var excludeExtensions = ['js', 'css', 'svg', 'ico', 'woff', 'png', 'jpg', 'jpeg', 'gif', 'pdf', 'json']; + var excludeExtensions = ['js', 'css', 'svg', 'ico', 'woff', 'png', 'jpg', 'jpeg', 'gif', 'pdf', 'json', 'zip', 'rar', 'tar', 'gz']; var ignore = opt.ignore || opt.excludeList || excludeExtensions.map(function (ext) { return new RegExp('\\.' + ext + '(\\?.*)?$'); }); From c3b4852f7612be3a96abf0848634968bcf4503ea Mon Sep 17 00:00:00 2001 From: "s.sharov" Date: Tue, 20 Dec 2016 16:05:16 +0300 Subject: [PATCH 3/3] README.md changed according to new default ignore value. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a90f88..af01108 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,8 @@ These are the available options with the following defaults: // regex: any expression: e.g. starts with pattern: /^.../ ends with pattern: /...$/ ignore: [ /\.js(\?.*)?$/, /\.css(\?.*)?$/, /\.svg(\?.*)?$/, /\.ico(\?.*)?$/, /\.woff(\?.*)?$/, - /\.png(\?.*)?$/, /\.jpg(\?.*)?$/, /\.jpeg(\?.*)?$/, /\.gif(\?.*)?$/, /\.pdf(\?.*)?$/ + /\.png(\?.*)?$/, /\.jpg(\?.*)?$/, /\.jpeg(\?.*)?$/, /\.gif(\?.*)?$/, /\.pdf(\?.*)?$/, + /\.zip(\?.*)?$/, /\.rar(\?.*)?$/, /\.tar(\?.*)?$/, /\.gz(\?.*)?$/ ], // include all urls by default