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:
+2
-4
@@ -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
@@ -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*)', () => {
|
||||
|
||||
Reference in New Issue
Block a user