From 7544211017c455500f3e3a7bf6787b71ced520e7 Mon Sep 17 00:00:00 2001 From: timtian Date: Mon, 11 May 2015 15:15:35 +0800 Subject: [PATCH] fix issues #1 Not replacing the hash #1 --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 764c240..fad9017 100644 --- a/index.js +++ b/index.js @@ -20,7 +20,13 @@ module.exports = function (options) { dateFormat : 'yyyymmddHHMM', revType:'hash', transformPath : function (orgPath, rev) { - var newpath = orgPath + (orgPath.indexOf('?') > -1 ? '&':'?') + options.suffix + '=' + rev; + var reg = new RegExp ('((\\?|\\&|\\&\\;)' + options.suffix + '=)([^&\\s]+)', 'gi'); + var newpath = orgPath; + if(reg.test(orgPath)){ + newpath = orgPath.replace(reg, "$1" + rev); + }else{ + newpath += ((orgPath.indexOf('?') > -1 ? '&':'?') + options.suffix + '=' + rev); + } return newpath }, elementAttributes :{