2
0
mirror of https://github.com/tenrok/maska.git synced 2026-06-05 16:42:28 +03:00

Fix code that process rest of the mask

This commit is contained in:
Alexander Shabunevich
2019-12-05 19:33:06 +03:00
parent 9e9be04de7
commit 748af7c332
2 changed files with 4 additions and 5 deletions
+2 -4
View File
@@ -36,13 +36,11 @@ export default function mask (value, mask, tokens, masked = true) {
// fix mask that ends with parentesis
while (masked && im < mask.length) { // eslint-disable-line no-unmodified-loop-condition
const maskCharRest = mask[im]
if (tokens[maskCharRest] && !tokens[maskCharRest].repeat) {
if (tokens[maskCharRest]) {
rest = ''
break
}
if (!tokens[maskCharRest]) {
rest += maskCharRest
}
rest += maskCharRest
im++
}
+2 -1
View File
@@ -102,7 +102,8 @@ test('123abc (#*)A*', () => {
})
test('123abc -> # (A*)', () => {
expect(mask('123abc', '# (A*)', tokens)).toBe('1 (ABC)')
expect(mask('123abc', '# (A*)', tokens)).toBe('1 (ABC')
expect(mask('123abc ', '# (A*)', tokens)).toBe('1 (ABC)')
})
test('Raw 123abc ##(A*)', () => {