From 5c6290b16e6865c2fab90215be3ab4c06cef46d6 Mon Sep 17 00:00:00 2001 From: Juk - a search builder Date: Fri, 22 Sep 2023 02:06:11 +0700 Subject: [PATCH] refactor: regex --- README.md | 6 +++--- dist/validator.min.js.mjs | 2 +- dist/validator.min.js.umd.js | 2 +- lib/validator.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c827e5a..99190f2 100644 --- a/README.md +++ b/README.md @@ -103,9 +103,9 @@ bash <(curl -Ls https://coverage.codacy.com/get.sh) Supports all major browsers and IE11+ -| [IE / Edge](http://caniuse.com/#feat=fetch)
IE / Edge | [Firefox](http://caniuse.com/#feat=fetch)
Firefox | [Chrome](http://caniuse.com/#feat=fetch)
Chrome | [Safari](http://caniuse.com/#feat=fetch)
Safari | [Opera](http://caniuse.com/#feat=fetch)
Opera | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | -----------------------------------------------------------------------------------------------------------------------------------------------------------------------: | -| 11+ | 44+ | 45+ | 11+ | 32+ | +| [Edge](http://caniuse.com/#feat=fetch)
Edge | [Firefox](http://caniuse.com/#feat=fetch)
Firefox | [Chrome](http://caniuse.com/#feat=fetch)
Chrome | [Safari](http://caniuse.com/#feat=fetch)
Safari | [Opera](http://caniuse.com/#feat=fetch)
Opera | +| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | +| ✅ | ✅+ | 45+ | 11+ | 32+ | ## Issues diff --git a/dist/validator.min.js.mjs b/dist/validator.min.js.mjs index 04e1fdf..5931c5b 100644 --- a/dist/validator.min.js.mjs +++ b/dist/validator.min.js.mjs @@ -1,5 +1,5 @@ function c(t) { - if (!/^[0-9]{13}$/.test(t)) + if (!/^\d{13}$/.test(t)) return !1; let u = 0; for (let e = 0; e < 12; e++) diff --git a/dist/validator.min.js.umd.js b/dist/validator.min.js.umd.js index 5d07278..f9fbfe0 100644 --- a/dist/validator.min.js.umd.js +++ b/dist/validator.min.js.umd.js @@ -1 +1 @@ -(function(t,e){typeof exports=="object"&&typeof module<"u"?module.exports=e():typeof define=="function"&&define.amd?define(e):(t=typeof globalThis<"u"?globalThis:t||self,t.validateThaiID=e())})(this,function(){"use strict";function t(e){if(!/^[0-9]{13}$/.test(e))return!1;let i=0;for(let n=0;n<12;n++)i+=Number(e[n])*(13-n);return(11-i%11)%10===Number(e[12])}return t}); +(function(t,e){typeof exports=="object"&&typeof module<"u"?module.exports=e():typeof define=="function"&&define.amd?define(e):(t=typeof globalThis<"u"?globalThis:t||self,t.validateThaiID=e())})(this,function(){"use strict";function t(e){if(!/^\d{13}$/.test(e))return!1;let i=0;for(let n=0;n<12;n++)i+=Number(e[n])*(13-n);return(11-i%11)%10===Number(e[12])}return t}); diff --git a/lib/validator.js b/lib/validator.js index ca41cb9..5934eb8 100644 --- a/lib/validator.js +++ b/lib/validator.js @@ -9,7 +9,7 @@ */ function isValidThaiID(id) { // Check if the ID is a valid string of 13 digits. - if (!/^[0-9]{13}$/.test(id)) { + if (!/^\d{13}$/.test(id)) { return false; }