question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

parsePhoneNumberFromString() returns undefined with "+0" number prefix.

See original GitHub issue

Calling parsePhoneNumberFromString("+0407123456", "AU") returns the value undefined.

This is caused by extractCountryCallingCode() on parse_.js line

// Fast abortion: country codes do not begin with a '0'
if (number[1] === '0')
{
	return {}  // returns by extractCountryCallingCode()
}
let { countryCallingCode, number } = extractCountryCallingCode(formatted_phone_number, default_country, metadata.metadata)

So countryCallingCode and number are now both undefined.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

16reactions
catamphetaminecommented, May 28, 2019

No, that’s a perfectly correct API interface and only weird code needs to hack around that.

5reactions
tohagancommented, May 28, 2019

Ok that’s a weird API interface but I can hack around it. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

libphonenumber-js - npm
Returns an instance of PhoneNumber class, or undefined if no phone number could be parsed: for example, when the string contains no phone...
Read more >
How to output numbers with leading zeros in JavaScript?
Is there a way to prepend leading zeros to numbers so that it results in a string of fixed length? For example, 5...
Read more >
Frequently Asked Questions (FAQ)
If the number is too short to be a valid phone number in this country, we do not remove the national prefix. For...
Read more >
Leading zero - Wikipedia
A leading zero is any 0 digit that comes before the first nonzero digit in a number string in positional notation. For example,...
Read more >
Using libphonenumber for International Phone Numbers
Libphonenumber is Google's formatting, parsing, and validation tool for international phone numbers. Learn how to use it in your global apps ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found