Skip to content

Commit

Permalink
fix: mask for national input (no pluscode)
Browse files Browse the repository at this point in the history
  • Loading branch information
mockturtl committed Sep 23, 2023
1 parent 29a0724 commit d0e9c1b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/types/country_with_phone_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class CountryWithPhoneCode {

/// If we want to get the mask without the country code, strip
/// out the country code from the mask now.
if (removeCountryCodeFromMask) {
if (isIntl && removeCountryCodeFromMask) {
/// Return the mask after the country code and 2 characters,
/// one for the leading + and the other for the space between
/// country code and number.
Expand Down
16 changes: 16 additions & 0 deletions test/flutter_libphonenumber_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ void main() {
reason: 'mask should not contain country code in it');
});
});

group('national format', () {
setUp(() => fmt = PhoneNumberFormat.national);

test('ignores removeCountryCodeFromMask', () async {
for (var flag in {true, false}) {
final res = subj.getPhoneMask(
format: fmt,
type: PhoneNumberType.mobile,
removeCountryCodeFromMask: flag);

expect(res, '(000) 000-0000',
reason: 'mask should not contain country code in it');
}
});
});
});

group('LibPhonenumberTextFormatter', () {
Expand Down

0 comments on commit d0e9c1b

Please sign in to comment.