sunjw / jstoolnpp

A JavaScript (JSON) tool for Notepad++ (formerly JSMinNpp) and Visual Studio Code.
GNU General Public License v2.0
284 stars 24 forks source link

JSFormat bug in regular expression (Version 1.2307.1) #144

Closed wangyi041228 closed 12 months ago

wangyi041228 commented 1 year ago

Version 1.2307.1 Text: for(var c in/(y+)/.test(i)&&(i=i.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),n)

Raw:

webpackJsonp([0],{"0xDb":function(t,i,e){"use strict";i.a=function(t,i){if(t){var e=new Date(t),n={"M+":e.getMonth()+1,"d+":e.getDate(),"H+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(var c in/(y+)/.test(i)&&(i=i.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+c+")").test(i)&&(i=i.replace(RegExp.$1,1===RegExp.$1.length?n[c]:("00"+n[c]).substr((""+n[c]).length)));return i}return""}}});

Formated

webpackJsonp([0], {
    "0xDb": function (t, i, e) {
        "use strict";
        i.a = function (t, i) {
            if (t) {
                var e = new Date(t),
                n = {
                    "M+": e.getMonth() + 1,
                    "d+": e.getDate(),
                    "H+": e.getHours(),
                    "m+": e.getMinutes(),
                    "s+": e.getSeconds(),
                    "q+": Math.floor((e.getMonth() + 3) / 3),
                    S: e.getMilliseconds()
                };
                for (var c in / (y + ) / .test(i) && (i = i.replace(RegExp.$1, (e.getFullYear() + "").substr(4 - RegExp.$1.length))), n)
                    new RegExp("(" + c + ")").test(i) && (i = i.replace(RegExp.$1, 1 === RegExp.$1.length ? n[c] : ("00" + n[c]).substr(("" + n[c]).length)));
                return i
            }
            return ""
        }
    }
});
sunjw commented 12 months ago

Fixed after 827cb5c18e5b3d353375b2194fd2a49c6b5160ea