diff --git a/includes/locale.inc b/includes/locale.inc index f667d30..670f757 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -207,10 +207,16 @@ function locale_language_from_url($languages) { case LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN: foreach ($languages as $language) { - $host = parse_url($language->domain, PHP_URL_HOST); - if ($host && ($_SERVER['HTTP_HOST'] == $host)) { - $language_url = $language->language; - break; + // Skip check if the language doesn't have a domain. + if ($language->domain) { + // Only compare the domains not the protocols or ports. + // Remove protocol and add http:// so parse_url works + $host = 'http://' . str_replace(array('http://', 'https://'), array('', ''), $language->domain); + $host = parse_url($host, PHP_URL_HOST); + if ($_SERVER['HTTP_HOST'] == $host) { + $language_url = $language->language; + break; + } } } break; diff --git a/modules/locale/locale.test b/modules/locale/locale.test index 6dad7e0..4b3197e 100644 --- a/modules/locale/locale.test +++ b/modules/locale/locale.test @@ -1901,7 +1901,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase { // Setup for domain negotiation, first configure the language to have domain // URL. - $edit = array('prefix' => '', 'domain' => "http://$language_domain"); + $edit = array('prefix' => '', 'domain' => "https://$language_domain:99"); $this->drupalPost("admin/config/regional/language/edit/$language", $edit, t('Save language')); // Set the site to use domain language negotiation.