Closed PCkelley closed 2 years ago
No no no, it all works as intended.
it('should format with national prefix when specifically instructed', () => {
// With national prefix.
formatNumber('88005553535', 'RU', 'NATIONAL').should.equal('8 (800) 555-35-35')
// Without national prefix via an explicitly set option.
formatNumber('88005553535', 'RU', 'NATIONAL', { nationalPrefix: false }).should.equal('800 555-35-35')
})
The test passes so it works.
Thank you for maintaining this library, it has been great to work with! I am currently working with the formatNational method on a phone number input project. I do not want the nationalNumber prefix to show in my project. I found documentation on setting the option for nationalPrefix to false
nationalPrefix: Boolean — Some phone numbers can be formatted both with national prefix and without it. In such cases the library defaults to "with national prefix" (for legacy reasons). Pass nationalPrefix: false option to force formatting without national prefix in such cases.
When looking into the code I realized that
format.nationalPrefixIsOptionalWhenFormattingInNationalFormat()
is always false when using a national number so passing in the option would never work. Then change I am submitting ot make this expression check for an || instead of && will make the formatter respect the nationalPrefix: false option