Comparing version 0.0.1 to 0.0.2
@@ -13,3 +13,3 @@ /** | ||
phone = phone.trim(); | ||
country = country.trim(); | ||
country = (country === null) ? '' : country.trim(); | ||
@@ -573,5 +573,3 @@ if (phone.match(/^\+/)) { | ||
if (country === null) { | ||
iso3166 = iso3166_data[iso3_map.USA]; | ||
} else { | ||
if (country) { | ||
if (country.length === 3) { | ||
@@ -608,2 +606,4 @@ //iso3 | ||
} | ||
} else { | ||
iso3166 = iso3166_data[iso3_map.USA]; | ||
} | ||
@@ -610,0 +610,0 @@ |
{ | ||
"name": "phone", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "With a given country and phone number, validate and format the phone number to E.164 standard", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index", |
@@ -13,2 +13,9 @@ var should = require('should'), | ||
describe("phone('+1 (817) 569-8900', null)", function() { | ||
it('returns +18175698900', function() { | ||
var result = phone('+1 (817) 569-8900', null); | ||
result.should.eql('+18175698900'); | ||
}); | ||
}); | ||
describe("phone('212345678', '')", function() { | ||
@@ -69,2 +76,9 @@ it('returns null', function() { | ||
describe("phone('6569-8900', null)", function() { | ||
it('returns null', function() { | ||
var result = (phone('6569-8900', null) === null); | ||
result.should.eql(true); | ||
}); | ||
}); | ||
describe("phone('+852 8-569-8900', 'HKG')", function() { | ||
@@ -71,0 +85,0 @@ it('returns +85285698900', function() { |
51868
733