From 224ceb9c0961caf4d49b8a102643d610a9ca12e7 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 30 Jul 2013 08:35:59 +1000 Subject: [PATCH] BUGFIX discard extra whitespace --- README.md | 4 ++++ lib/global_phone/number.rb | 2 +- test/edge_test.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 993833a..6af6fbe 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,10 @@ GlobalPhone is heavily inspired by Andreas Gal's [PhoneNumber.js](https://github ### Version History +**1.0.2** (Unreleased) + +* BUGFIX discard extra whitespace when splitting phone numbers + **1.0.1** (May 29, 2013) * GlobalPhone::Number#to_s returns the E.164 international string. diff --git a/lib/global_phone/number.rb b/lib/global_phone/number.rb index 7f209a5..f22a367 100644 --- a/lib/global_phone/number.rb +++ b/lib/global_phone/number.rb @@ -8,7 +8,7 @@ class Number VALID_ALPHA_CHARS = /[a-zA-Z]/ LEADING_PLUS_CHARS = /^\++/ NON_DIALABLE_CHARS = /[^,#+\*\d]/ - SPLIT_FIRST_GROUP = /^(\d+)(.*)$/ + SPLIT_FIRST_GROUP = /^(\d+)\W*(.*)$/ def self.normalize(string) string.to_s. diff --git a/test/edge_test.rb b/test/edge_test.rb index 0b4e48f..69fe71f 100644 --- a/test/edge_test.rb +++ b/test/edge_test.rb @@ -15,7 +15,7 @@ class EdgeTest < TestCase # We don't include those formats in our database, so we fall # back to the closest match. number = context.parse("1520123456", "IE") - assert_equal "1520 123 456", number.national_format + assert_equal "1520 123 456", number.national_format end end end