From 816865b3b9064971c5ae8d1997b3a53abcf829ea Mon Sep 17 00:00:00 2001
From: Lloyd Hilaiel <lloyd@hilaiel.com>
Date: Tue, 3 May 2011 08:59:45 -0600
Subject: [PATCH] more substitution fun in test harness.  find places where
 hostname:port is explicit without scheme prepended and get those subbed
 correctly (like in host-meta files)

---
 run.js | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/run.js b/run.js
index f5a48ff58..6daf0cecd 100644
--- a/run.js
+++ b/run.js
@@ -34,8 +34,18 @@ function subHostNames(data) {
     data = data.replace(new RegExp(from, 'g'), to);
 
     // now do another replacement to catch bare hostnames sans http(s)
-    from = (from.substr(0,5) === 'https' ? from.substr(8) : from.substr(7));
-    data = data.replace(new RegExp(from, 'g'), to.substr(7));
+    // and explicit cases where port is appended
+    var fromWithPort;
+    if (from.substr(0,5) === 'https') {
+        from = from.substr(8);
+        fromWithPort = from + ":443";
+    } else {
+        from = from.substr(7);
+        fromWithPort = from + ":80";
+    }
+    to = to.substr(7);
+    data = data.replace(new RegExp(fromWithPort, 'g'), to);
+    data = data.replace(new RegExp(from, 'g'), to);
   }
   return data;
 }
-- 
GitLab