Parse meetup.com event locations with USA suffix

Now the event location parser can parse the addresses with
USA suffix, and removes backslashes in address normalization.

Change-Id: Idc66f04395104540a13b888d4d9e2a91d9033448
This commit is contained in:
Marton Kiss 2015-03-23 17:38:45 +01:00
parent 8b4e819a46
commit 75d4303d31
2 changed files with 13 additions and 0 deletions

View File

@ -97,4 +97,13 @@ class MeetupLocationParserTest extends DrupalUnitTestCase {
$this->assertEqual('Blue Box Group', $result['venue']);
}
function testAddressPartWithSlash() {
$location = 'Redapt Systems (12226 134th Ct Ne\, Redmond\, WA\, USA)';
$result = _parse_meetup_location($location);
$this->assertEqual('Redapt Systems', $result['venue']);
$this->assertEqual('12226 134th Ct Ne', $result['address']);
$this->assertEqual('Redmond, WA', $result['city']);
$this->assertEqual('United States', $result['country']);
}
}

View File

@ -210,6 +210,9 @@ function _us_states_get_predefined_list() {
function _match_us_location($elements) {
$us_states = _us_states_get_predefined_list();
$state_part = array_shift($elements);
if ($state_part == 'USA') {
$state_part = array_shift($elements);
}
if (strlen($state_part == 2)) {
$state_code = $state_part;
} else {
@ -250,6 +253,7 @@ function _match_location_by_country($elements) {
* address parts as array elements
*/
function _normalize_address_elements($address_part) {
$address_part = stripslashes($address_part);
$address_elements = explode(', ', rtrim($address_part, ')'));
foreach ($address_elements as $k => $v) {
$address_elements[$k] = trim($v);