Bug 998372 - part 1 - lift regex construction out of FindProxyForURL; r=jmaher
authorNathan Froyd <froydnj@mozilla.com>
Fri, 18 Apr 2014 12:16:11 -0400
changeset 179525 005a3405219cf1595cf2ada6c128ed1d17efdbfc
parent 179524 dd9b23471fc136175f8e0d246e27cdb515d706ab
child 179526 0a42f8424ccba8d77bdd777d84d62e3311164a13
push id26629
push userryanvm@gmail.com
push dateTue, 22 Apr 2014 19:42:36 +0000
treeherdermozilla-central@9f20e885fa3a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs998372
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 998372 - part 1 - lift regex construction out of FindProxyForURL; r=jmaher
testing/mozbase/mozprofile/mozprofile/permissions.py
--- a/testing/mozbase/mozprofile/mozprofile/permissions.py
+++ b/testing/mozbase/mozprofile/mozprofile/permissions.py
@@ -303,25 +303,26 @@ class Permissions(object):
         if isinstance(user_proxy, dict):
             proxy.update(user_proxy)
 
         # TODO: this should live in a template!
         # TODO: So changing the 5th line of the regex below from (\\\\\\\\d+)
         # to (\\\\d+) makes this code work. Not sure why there would be this
         # difference between automation.py.in and this file.
         pacURL = """data:text/plain,
+var uriRegex = new RegExp('^([a-z][-a-z0-9+.]*)' +
+                          '://' +
+                          '(?:[^/@]*@)?' +
+                          '(.*?)' +
+                          '(?::(\\\\d+))?/');
+
 function FindProxyForURL(url, host)
 {
   var origins = [%(origins)s];
-  var regex = new RegExp('^([a-z][-a-z0-9+.]*)' +
-                         '://' +
-                         '(?:[^/@]*@)?' +
-                         '(.*?)' +
-                         '(?::(\\\\d+))?/');
-  var matches = regex.exec(url);
+  var matches = uriRegex.exec(url);
   if (!matches)
     return 'DIRECT';
   var isHttp = matches[1] == 'http';
   var isHttps = matches[1] == 'https';
   var isWebSocket = matches[1] == 'ws';
   var isWebSocketSSL = matches[1] == 'wss';
   if (!matches[3])
   {