From e80e08980bce6840d1ae72f7a012aef5eb12b4ea Mon Sep 17 00:00:00 2001 From: Hilke Heremans Date: Thu, 8 Sep 2016 10:24:28 +0200 Subject: [PATCH] Fix modifier issue for originals in root path --- src/lib/modifiers.js | 4 ++-- test/src/lib/modifiers-spec.js | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/modifiers.js b/src/lib/modifiers.js index 35cb48a..9d45005 100644 --- a/src/lib/modifiers.js +++ b/src/lib/modifiers.js @@ -301,8 +301,8 @@ exports.parse = function(requestUrl, namedMods, envOverride){ crop = getModifier('c'); quality = getModifier('q'); segments = requestUrl.replace(/^\//,'').split('/'); - modStr = _.first(segments); - image = _.last(segments).toLowerCase(); + image = (segments.splice(-1,1)[0] || "").toLowerCase(); + modStr = _.first(segments) || ""; namedMods = typeof namedMods === 'undefined' ? namedModifierMap : namedMods; diff --git a/test/src/lib/modifiers-spec.js b/test/src/lib/modifiers-spec.js index 2cbe7d1..9a93f2b 100644 --- a/test/src/lib/modifiers-spec.js +++ b/test/src/lib/modifiers-spec.js @@ -48,6 +48,12 @@ describe('Modifiers module', function(){ mod.parse(request, undefined, localEnv).width.should.equal(500); mod.parse(request, undefined, localEnv).height.should.equal(500); }); + + it('should not set hasModStr when no folder is specified', function() { + var request = 'qistf72.jpg'; + mod.parse(request).hasModStr.should.not.be.true; + }) + });