Index: domain_user_default.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain_user_default/domain_user_default.module,v
retrieving revision 1.1.2.11
diff -u -p -r1.1.2.11 domain_user_default.module
--- domain_user_default.module	20 Oct 2008 16:18:10 -0000	1.1.2.11
+++ domain_user_default.module	25 Nov 2008 00:26:23 -0000
@@ -73,6 +73,11 @@ function domain_user_default_menu() {
  * forced, or forced only on entry to the main domain.
  */
 function domain_user_default_init() {
+  if (_domain_user_default_is_internal_path()) {
+    // On internal paths, do nothing.
+    return;
+  }
+
   global $user, $_domain;
 
   // Must load full user object.
@@ -377,3 +382,28 @@ function _domain_user_default_no_redirec
   // behavior set to 1 indicates a redirect only on matches
   return $matches xor $behavior;
 }
+
+/**
+ * Determine if a path is internal to this module.
+ */
+function _domain_user_default_is_internal_path() {
+  $internal_paths = array(
+    'search/domain*',
+    'domain-user-default/set*',
+    'domains',
+    'domains/*',
+  );
+  if (module_exists('domain_geolocalization')) {
+    $internal_paths[] = 'domain-geolocalization*';
+  }
+  $internal_paths = implode("\n", $internal_paths);
+
+  $path = drupal_get_path_alias($_GET['q']);
+  $matches = drupal_match_path($path, $internal_paths);
+  if ($path != $_GET['q']) {
+    // Match path or alias.
+    $matches = $matches || drupal_match_path($_GET['q'], $internal_paths);
+  }
+
+  return $matches;
+}
