Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

awesome-phonenumber

Package Overview
Dependencies
Maintainers
1
Versions
166
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awesome-phonenumber - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

2

package.json

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "1.0.5",
"version": "1.0.6",
"author": "Gustaf Räntilä <g.rantila@gmail.com>",

@@ -8,0 +8,0 @@ "repository": {

@@ -68,3 +68,26 @@ 'use strict';

function extractRegionCode( phoneNumber )
{
if ( phoneNumber.charAt( 0 ) !== '+' || phoneNumber.length < 5 )
return null;
var firstOne = phoneNumber.substr( 1, 1 );
var firstTwo = phoneNumber.substr( 1, 2 );
var firstThree = phoneNumber.substr( 1, 3 );
var regionCode;
regionCode = PhoneNumber.getRegionCodeForCountryCode( firstOne );
if ( regionCode !== 'ZZ' )
return regionCode;
regionCode = PhoneNumber.getRegionCodeForCountryCode( firstTwo );
if ( regionCode !== 'ZZ' )
return regionCode;
regionCode = PhoneNumber.getRegionCodeForCountryCode( firstThree );
if ( regionCode !== 'ZZ' )
return regionCode;
}
/**

@@ -97,2 +120,18 @@ * The PhoneNumber class.

if ( !isInternal )
{
if ( regionCode && ( phoneNumber.charAt( 0 ) === '+' ) )
{
// Ensure region code is valid
var cc = PhoneNumber.getCountryCodeForRegionCode( regionCode );
if ( phoneNumber.substr( 1, cc.length ) !== cc )
// Wrong region code, let's fix it
regionCode = null;
}
if ( !regionCode )
// Guess region code
regionCode = extractRegionCode( phoneNumber );
}
this._json = {

@@ -150,3 +189,6 @@ 'number' : { },

{
return phoneUtil.getRegionCodeForCountryCode( countryCode );
var regionCode = phoneUtil.getRegionCodeForCountryCode( countryCode );
if ( regionCode.substr( 0, 2 ) === '00' )
return PhoneNumber.getRegionCodeForCountryCode( regionCode.substr( 2 ) );
return regionCode;
}

@@ -153,0 +195,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc