Skip to content

Commit

Permalink
Fixed #531 - inputNumber with numeric prefix is not working as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Oct 9, 2020
1 parent 946e3b2 commit 2bb7300
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/inputnumber/InputNumber.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export default {
this.constructParser();
}
},
escapeRegExp(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
},
getDecimalExpression() {
const formatter = new Intl.NumberFormat(this.locale, {useGrouping: false});
return new RegExp(`[${formatter.format(1.1).trim().replace(this._numeral, '')}]`, 'g');
Expand Down Expand Up @@ -219,7 +222,7 @@ export default {
this.prefixChar = formatter.format(1).split('1')[0];
}
return new RegExp(`${this.prefixChar||''}`, 'g');
return new RegExp(`${this.escapeRegExp(this.prefixChar||'')}`, 'g');
},
getSuffixExpression() {
if (this.props.suffix) {
Expand All @@ -231,7 +234,7 @@ export default {
this.suffixChar = formatter.format(1).split('1')[1];
}
return new RegExp(`${this.suffixChar||''}`, 'g');
return new RegExp(`${this.escapeRegExp(this.suffixChar||'')}`, 'g');
},
formatValue(value) {
if (value != null) {
Expand Down

0 comments on commit 2bb7300

Please sign in to comment.