Index: domain.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/domain/domain.module,v
retrieving revision 1.40.2.7
diff -u -r1.40.2.7 domain.module
--- domain.module   20 Apr 2008 22:07:17 -0000   1.40.2.7
+++ domain.module   16 Jun 2008 02:41:30 -0000
@@ -40,8 +40,8 @@
 function domain_init() {
   global $_domain, $conf;
   $_domain = array();
-  // Cribbed from bootstrap.inc -- removes port protocols from the host value.
-  $_subdomain = strtolower(implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
+  // Removes port protocols from the host value.
+  $_subdomain = strtolower(preg_replace('/:[0-9]+$/', '', rtrim($_SERVER['HTTP_HOST'])));
 
   // Strip the www. off the subdomain, if required by the module settings.
   $raw_domain = $_subdomain;
@@ -538,7 +538,7 @@
   if (substr($_url['path'], -1) != '/') {
     $_url['path'] .= '/';
   }
-  $path = $domain['scheme'] .'://'. $domain['subdomain'] . $_url['path'];
+  $path = $domain['scheme'] .'://'. $domain['subdomain'] . (isset($_url['port']) ? ':'. $_url['port'] : '') . $_url['path'];
   return $path;
 }

