Index: elf.module
===================================================================
--- elf.module	(revision 1039)
+++ elf.module	(revision 1761)
@@ -51,6 +51,13 @@
     '#title' => t('Add JS to open external links in a new window'),
     '#description' => t('When enabled, this will include inline JS that causes all external links to open in a new browser window.'),
   );
+  
+  $form['elf_hostnames'] = array(
+    '#type' => 'textarea',
+    '#default_value' => variable_get('elf_hostnames', ''),
+    '#title' => t('Additional hostnames that count as internal'),
+    '#description' => t('This <em>comma separated</em> list of hostnames / URLs is also considered internal, links that match these will not be opened in a new window. These are passed through to the PHP <a href="http://www.php.net/strpos" title="PHP manual page on strpos">strpos</a> function, if you need to manipulate it further.'),
+  );
 
   return system_settings_form($form);
 }
@@ -68,7 +75,7 @@
 
     case 'process':
       // find all <a> tags and match their href so we can test if the link is external or not
-      $text = preg_replace_callback('!<a.*?href="([^"]+)".*?>!', elf_replace, $text);
+      $text = preg_replace_callback('!<a.*?href="([^"]+)".*?>!', 'elf_replace', $text);
       return $text;
 
     default:
@@ -76,12 +83,19 @@
   }
 }
 
+/**
+ * Master function that inserts the code to indicate whether the URL is external
+ */
 function elf_replace($match) {
   $link = $match[0];
   $site_url = url(NULL, NULL, NULL, TRUE);
+  $extras = array_filter(explode(',', variable_get('elf_hostnames', '')), 'strlen');
+  if (count($extras) > 0) {
+    $site_url = array_merge(array($site_url), $extras);
+  }
 
   // if the link is external (e.g., it starts with http) and it's not an absolute link to the current site
-  if (strpos($match[1], 'http') === 0 && strpos($match[1], $site_url) === FALSE) {
+  if (strpos($match[1], 'http') === 0 && _elf_search($match[1], $site_url) == FALSE) {
     // if there is no class
     if (strpos($match[0], 'class="') === FALSE) {
       // it is faster to use PHP's string functions then complex regexes
@@ -111,3 +125,21 @@
 
   return $link;
 }
+
+/**
+ * Master function used to decide whether the URL matches
+ */
+function _elf_search($match, $site_url) {
+  $found = FALSE;
+  if (is_array($site_url)) {
+    foreach($site_url as $i=>$url) {
+      if (strpos($match, $url) !== FALSE) {
+        $found = TRUE;
+      }
+    }
+  }
+  else {
+    $found = strpos($match, $site_url);
+  }
+  return $found;
+}
\ No newline at end of file
