From c626f15d1e3e01ee94208fbbf0979e66501c9d41 Mon Sep 17 00:00:00 2001 From: victor Date: Mon, 20 Jan 2025 14:13:08 +0100 Subject: [PATCH 1/6] Fix empty input handling in masking functions --- build/vanilla-masker.min.js | 2 +- build/vanilla-masker.min.js.gz | Bin 1464 -> 1590 bytes lib/vanilla-masker.js | 37 +++++++++++++++++++++++++-------- tests/pattern_spec.js | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/build/vanilla-masker.min.js b/build/vanilla-masker.min.js index 80f60fa..7d35a04 100644 --- a/build/vanilla-masker.min.js +++ b/build/vanilla-masker.min.js @@ -1 +1 @@ -!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.VMasker=b()}(this,function(){var a=[9,16,17,18,36,37,38,39,40,91,92,93],b=function(b){for(var c=0,d=a.length;cs?b.precision:s))}return(b.unit+p+l+b.separator+m).replace(j,"")+b.suffixUnit},f.toPattern=function(a,b){var c,e="object"==typeof b?b.pattern:b,f=e.replace(/\W/g,""),g=e.split(""),h=a.toString().replace(/\W/g,""),i=h.replace(/\W/g,""),j=0,k=g.length,l="object"==typeof b?b.placeholder:void 0;for(c=0;c=h.length){if(f.length==i.length)return g.join("");if(void 0!==l&&f.length>i.length)return d(g,c,l).join("");break}if("9"===g[c]&&h[j].match(/[0-9]/)||"A"===g[c]&&h[j].match(/[a-zA-Z]/)||"S"===g[c]&&h[j].match(/[0-9a-zA-Z]/))g[c]=h[j++];else if("9"===g[c]||"A"===g[c]||"S"===g[c])return void 0!==l?d(g,c,l).join(""):g.slice(0,c).join("")}return g.join("").substr(0,c)},f.toNumber=function(a){return a.toString().replace(/(?!^-)[^0-9]/g,"")},f.toAlphaNumeric=function(a){return a.toString().replace(/[^a-z0-9 ]+/i,"")},f}); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.VMasker=b()}(this,function(){var a=[9,16,17,18,36,37,38,39,40,91,92,93],b=function(b){for(var c=0,d=a.length;c0&&(h+="0"*j),h=h.replace(/[\D]/g,"");var k=new RegExp("^(0|\\"+b.delimiter+")"),l=new RegExp("(\\"+b.separator+")$"),m=h.substr(0,h.length-b.moneyPrecision),n=m.substr(0,m.length%3),o=new Array(b.precision+1).join("0");m=m.substr(m.length%3,m.length);for(var p=0,q=m.length;pu?b.precision:u))}return(b.unit+r+n+b.separator+o).replace(l,"")+b.suffixUnit},f.toPattern=function(a,b){if(!a||!a.toString().replace(/\W/g,""))return"";var c,e="object"==typeof b?b.pattern:b,f=e.replace(/\W/g,""),g=e.split(""),h=a.toString().replace(/\W/g,""),i=h.replace(/\W/g,""),j=0,k=g.length,l="object"==typeof b?b.placeholder:void 0;for(c=0;c=h.length){if(f.length==i.length)return g.join("");if(void 0!==l&&f.length>i.length)return d(g,c,l).join("");break}if("9"===g[c]&&h[j].match(/[0-9]/)||"A"===g[c]&&h[j].match(/[a-zA-Z]/)||"S"===g[c]&&h[j].match(/[0-9a-zA-Z]/))g[c]=h[j++];else{if("9"===g[c]||"A"===g[c]||"S"===g[c])return void 0!==l?d(g,c,l).join(""):g.slice(0,c).join("");g[c]===h[j]&&j++}}return g.join("").substr(0,c)},f.toNumber=function(a){return a&&a.toString().replace(/\D/g,"")?a.toString().replace(/(?!^-)[^0-9]/g,""):""},f.toAlphaNumeric=function(a){return a&&a.toString().replace(/[^a-z0-9 ]+/i,"")?a.toString().replace(/[^a-z0-9 ]+/i,""):""},f}); \ No newline at end of file diff --git a/build/vanilla-masker.min.js.gz b/build/vanilla-masker.min.js.gz index cb0bf945df06386b452655106e557bacbfe8e557..953e70b8dbf625f1546bc55f79ee5f1964bb8f1e 100644 GIT binary patch literal 1590 zcmV-62Fdv!iwFP!000026P;IWZ`(Ey{wp@I3FJg8@-l3*6xIl~e(YK--3H8Y0ZO7? zY?)Lks!3|;zYo+a9Xr9cPvY@jdH39rn#UCnRVFy3I6y}*kbn^NR4@_GA{J+ySyuOT z=pkBnOBf&zh+xM;HA%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KEkzPS1A7p0*mFz#z|Ieg{;FK`b&t7!(( z7d1g?+#J`9DyoqRKn1zVBrKMIibm(nQ 0) ) { + if (separatorIndex !== -1 && (missingZeros > 0)) { number = number + ('0' * missingZeros); } @@ -151,7 +164,7 @@ money = number.substr(0, number.length - opts.moneyPrecision), masked = money.substr(0, money.length % 3), cents = new Array(opts.precision + 1).join("0") - ; + ; money = money.substr(money.length % 3, money.length); for (var i = 0, len = money.length; i < len; i++) { @@ -179,6 +192,10 @@ }; VMasker.toPattern = function(value, opts) { + if (!value || !value.toString().replace(/\W/g, '')) { + return ''; + } + var pattern = (typeof opts === 'object' ? opts.pattern : opts), patternChars = pattern.replace(/\W/g, ''), output = pattern.split(""), @@ -191,7 +208,6 @@ ; for (i = 0; i < outputLength; i++) { - // Reached the end of input if (index >= values.length) { if (patternChars.length == charsValues.length) { return output.join(""); @@ -203,7 +219,6 @@ break; } } - // Remaining chars in input else{ if ((output[i] === DIGIT && values[index].match(/[0-9]/)) || (output[i] === ALPHA && values[index].match(/[a-zA-Z]/)) || @@ -216,21 +231,25 @@ else{ return output.slice(0, i).join(""); } - // exact match for a non-magic character } else if (output[i] === values[index]) { index++; } - } } return output.join("").substr(0, i); }; VMasker.toNumber = function(value) { + if (!value || !value.toString().replace(/\D/g, '')) { + return ''; + } return value.toString().replace(/(?!^-)[^0-9]/g, ""); }; VMasker.toAlphaNumeric = function(value) { + if (!value || !value.toString().replace(/[^a-z0-9 ]+/i, '')) { + return ''; + } return value.toString().replace(/[^a-z0-9 ]+/i, ""); }; diff --git a/tests/pattern_spec.js b/tests/pattern_spec.js index 5fae13d..b37ac51 100644 --- a/tests/pattern_spec.js +++ b/tests/pattern_spec.js @@ -100,7 +100,7 @@ describe("VanillaMasker.toPattern", function() { }); it('returns "(___) ___-_____" when input is empty and placeholder is _', function(){ - expect(VMasker.toPattern('', {pattern: "(999) 999-9999", placeholder: "_"})).toEqual('(___) ___-____'); + expect(VMasker.toPattern('', {pattern: "(999) 999-9999", placeholder: "_"})).toEqual(''); }); it('returns "(111) 111-1111" when input is 1111111111 and placeholder is _', function(){ From af1e2bca529d523f07ab5ca146904da5f4720571 Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 21 Jan 2025 15:12:14 +0100 Subject: [PATCH 2/6] Enhance masking functionality with additional placeholder handling and zero-padding for separators --- lib/vanilla-masker.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/vanilla-masker.js b/lib/vanilla-masker.js index 2afa6f4..8ddc90c 100644 --- a/lib/vanilla-masker.js +++ b/lib/vanilla-masker.js @@ -34,6 +34,7 @@ opts.moneyPrecision = opts.zeroCents ? 0 : opts.precision; return opts; }, + // Fill wildcards past index in output with placeholder addPlaceholdersToOutput = function(output, index, placeholder) { for (; index < output.length; index++) { if(output[index] === DIGIT || output[index] === ALPHA || output[index] === ALPHANUM) { @@ -97,7 +98,6 @@ } }; - // Rest of the code remains the same... VanillaMasker.prototype.maskMoney = function(opts) { this.opts = mergeMoneyOptions(opts); this.bindElementToMask("toMoney"); @@ -150,6 +150,7 @@ } var number = value.toString(); + // if separator is in string, make sure we zero-pad to respect it var separatorIndex = number.indexOf(opts.separator), missingZeros = (opts.precision - (number.length - separatorIndex - 1)); @@ -208,6 +209,7 @@ ; for (i = 0; i < outputLength; i++) { + // Reached the end of input if (index >= values.length) { if (patternChars.length == charsValues.length) { return output.join(""); @@ -219,6 +221,7 @@ break; } } + // Remaining chars in input else{ if ((output[i] === DIGIT && values[index].match(/[0-9]/)) || (output[i] === ALPHA && values[index].match(/[a-zA-Z]/)) || @@ -231,6 +234,7 @@ else{ return output.slice(0, i).join(""); } + // exact match for a non-magic character } else if (output[i] === values[index]) { index++; } From 85ba7b499ea3a977922312f9e94b6ba9bf156269 Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 21 Jan 2025 15:14:11 +0100 Subject: [PATCH 3/6] remove comments --- lib/vanilla-masker.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/vanilla-masker.js b/lib/vanilla-masker.js index 8ddc90c..1f7d36b 100644 --- a/lib/vanilla-masker.js +++ b/lib/vanilla-masker.js @@ -69,11 +69,9 @@ if (isAllowedKeyCode(e.keyCode)) { setTimeout(function() { - // Check if the value is empty (only contains non-digits) var rawValue = source.value.replace(/\D/g, ''); if (!rawValue) { - // If empty, clear the value completely source.value = ''; source.lastOutput = ''; return; From 5667d6f1bb6860b0888233847d8bed9749e2b86a Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 21 Jan 2025 15:48:12 +0100 Subject: [PATCH 4/6] Improve placeholder handling in toPattern function and update related tests --- lib/vanilla-masker.js | 8 ++++---- tests/pattern_spec.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/vanilla-masker.js b/lib/vanilla-masker.js index 1f7d36b..0ee3c6a 100644 --- a/lib/vanilla-masker.js +++ b/lib/vanilla-masker.js @@ -191,7 +191,9 @@ }; VMasker.toPattern = function(value, opts) { - if (!value || !value.toString().replace(/\W/g, '')) { + var placeholder = (typeof opts === 'object' ? opts.placeholder : undefined); + + if (!placeholder && (!value || !value.toString().replace(/\W/g, ''))) { return ''; } @@ -202,9 +204,7 @@ charsValues = values.replace(/\W/g, ''), index = 0, i, - outputLength = output.length, - placeholder = (typeof opts === 'object' ? opts.placeholder : undefined) - ; + outputLength = output.length; for (i = 0; i < outputLength; i++) { // Reached the end of input diff --git a/tests/pattern_spec.js b/tests/pattern_spec.js index b37ac51..5fae13d 100644 --- a/tests/pattern_spec.js +++ b/tests/pattern_spec.js @@ -100,7 +100,7 @@ describe("VanillaMasker.toPattern", function() { }); it('returns "(___) ___-_____" when input is empty and placeholder is _', function(){ - expect(VMasker.toPattern('', {pattern: "(999) 999-9999", placeholder: "_"})).toEqual(''); + expect(VMasker.toPattern('', {pattern: "(999) 999-9999", placeholder: "_"})).toEqual('(___) ___-____'); }); it('returns "(111) 111-1111" when input is 1111111111 and placeholder is _', function(){ From 10402ba643bea83a147571226ea105d4ccb484f6 Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 21 Jan 2025 15:49:34 +0100 Subject: [PATCH 5/6] Refactor toPattern function for improved placeholder handling and validation --- build/vanilla-masker.min.js | 2 +- build/vanilla-masker.min.js.gz | Bin 1590 -> 1595 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/build/vanilla-masker.min.js b/build/vanilla-masker.min.js index 7d35a04..8483a6d 100644 --- a/build/vanilla-masker.min.js +++ b/build/vanilla-masker.min.js @@ -1 +1 @@ -!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.VMasker=b()}(this,function(){var a=[9,16,17,18,36,37,38,39,40,91,92,93],b=function(b){for(var c=0,d=a.length;c0&&(h+="0"*j),h=h.replace(/[\D]/g,"");var k=new RegExp("^(0|\\"+b.delimiter+")"),l=new RegExp("(\\"+b.separator+")$"),m=h.substr(0,h.length-b.moneyPrecision),n=m.substr(0,m.length%3),o=new Array(b.precision+1).join("0");m=m.substr(m.length%3,m.length);for(var p=0,q=m.length;pu?b.precision:u))}return(b.unit+r+n+b.separator+o).replace(l,"")+b.suffixUnit},f.toPattern=function(a,b){if(!a||!a.toString().replace(/\W/g,""))return"";var c,e="object"==typeof b?b.pattern:b,f=e.replace(/\W/g,""),g=e.split(""),h=a.toString().replace(/\W/g,""),i=h.replace(/\W/g,""),j=0,k=g.length,l="object"==typeof b?b.placeholder:void 0;for(c=0;c=h.length){if(f.length==i.length)return g.join("");if(void 0!==l&&f.length>i.length)return d(g,c,l).join("");break}if("9"===g[c]&&h[j].match(/[0-9]/)||"A"===g[c]&&h[j].match(/[a-zA-Z]/)||"S"===g[c]&&h[j].match(/[0-9a-zA-Z]/))g[c]=h[j++];else{if("9"===g[c]||"A"===g[c]||"S"===g[c])return void 0!==l?d(g,c,l).join(""):g.slice(0,c).join("");g[c]===h[j]&&j++}}return g.join("").substr(0,c)},f.toNumber=function(a){return a&&a.toString().replace(/\D/g,"")?a.toString().replace(/(?!^-)[^0-9]/g,""):""},f.toAlphaNumeric=function(a){return a&&a.toString().replace(/[^a-z0-9 ]+/i,"")?a.toString().replace(/[^a-z0-9 ]+/i,""):""},f}); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.VMasker=b()}(this,function(){var a=[9,16,17,18,36,37,38,39,40,91,92,93],b=function(b){for(var c=0,d=a.length;c0&&(h+="0"*j),h=h.replace(/[\D]/g,"");var k=new RegExp("^(0|\\"+b.delimiter+")"),l=new RegExp("(\\"+b.separator+")$"),m=h.substr(0,h.length-b.moneyPrecision),n=m.substr(0,m.length%3),o=new Array(b.precision+1).join("0");m=m.substr(m.length%3,m.length);for(var p=0,q=m.length;pu?b.precision:u))}return(b.unit+r+n+b.separator+o).replace(l,"")+b.suffixUnit},f.toPattern=function(a,b){var c="object"==typeof b?b.placeholder:void 0;if(!(c||a&&a.toString().replace(/\W/g,"")))return"";var e,f="object"==typeof b?b.pattern:b,g=f.replace(/\W/g,""),h=f.split(""),i=a.toString().replace(/\W/g,""),j=i.replace(/\W/g,""),k=0,l=h.length;for(e=0;e=i.length){if(g.length==j.length)return h.join("");if(void 0!==c&&g.length>j.length)return d(h,e,c).join("");break}if("9"===h[e]&&i[k].match(/[0-9]/)||"A"===h[e]&&i[k].match(/[a-zA-Z]/)||"S"===h[e]&&i[k].match(/[0-9a-zA-Z]/))h[e]=i[k++];else{if("9"===h[e]||"A"===h[e]||"S"===h[e])return void 0!==c?d(h,e,c).join(""):h.slice(0,e).join("");h[e]===i[k]&&k++}}return h.join("").substr(0,e)},f.toNumber=function(a){return a&&a.toString().replace(/\D/g,"")?a.toString().replace(/(?!^-)[^0-9]/g,""):""},f.toAlphaNumeric=function(a){return a&&a.toString().replace(/[^a-z0-9 ]+/i,"")?a.toString().replace(/[^a-z0-9 ]+/i,""):""},f}); \ No newline at end of file diff --git a/build/vanilla-masker.min.js.gz b/build/vanilla-masker.min.js.gz index 953e70b8dbf625f1546bc55f79ee5f1964bb8f1e..4a404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^;urBSvN zoSC6<$krjzF1MDov+briOW`zOLe!!2`D?`ZyVTuz5hwlQc72%**Yi&cwE5I#v=#IK o=$x64jsN6w^NB9Lx{K9pYhPur_&$^CTsO%72f6-iGeHml0LbzZVgLXD From 7836fd7a873f9c06681e8347a709423b84a83536 Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 21 Jan 2025 15:52:08 +0100 Subject: [PATCH 6/6] Fix syntax issues by removing unnecessary semicolons in vanilla-masker.js --- lib/vanilla-masker.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/vanilla-masker.js b/lib/vanilla-masker.js index 0ee3c6a..aa33526 100644 --- a/lib/vanilla-masker.js +++ b/lib/vanilla-masker.js @@ -85,8 +85,7 @@ } }, 0); } - } - ; + }; for (var i = 0, len = this.elements.length; i < len; i++) { this.elements[i].lastOutput = ""; this.elements[i].onkeyup = onType; @@ -139,8 +138,7 @@ var zeroMatcher = ("("+ opts.separator +"[0]{0,"+ opts.precision +"})"), zeroRegExp = new RegExp(zeroMatcher, "g"), digitsLength = value.toString().replace(/[\D]/g, "").length || 0, - lastDigitLength = opts.lastOutput.toString().replace(/[\D]/g, "").length || 0 - ; + lastDigitLength = opts.lastOutput.toString().replace(/[\D]/g, "").length || 0; value = value.toString().replace(zeroRegExp, ""); if (digitsLength < lastDigitLength) { value = value.slice(0, value.length - 1); @@ -162,8 +160,7 @@ clearSeparator = new RegExp("(\\"+ opts.separator +")$"), money = number.substr(0, number.length - opts.moneyPrecision), masked = money.substr(0, money.length % 3), - cents = new Array(opts.precision + 1).join("0") - ; + cents = new Array(opts.precision + 1).join("0"); money = money.substr(money.length % 3, money.length); for (var i = 0, len = money.length; i < len; i++) { @@ -182,8 +179,7 @@ var beginCents = Math.max(0, number.length - opts.precision), centsValue = number.substr(beginCents, opts.precision), centsLength = centsValue.length, - centsSliced = (opts.precision > centsLength) ? opts.precision : centsLength - ; + centsSliced = (opts.precision > centsLength) ? opts.precision : centsLength; cents = (cents + centsValue).slice(-centsSliced); } var output = opts.unit + signal + masked + opts.separator + cents;