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 198109 0c24e6699b718eba5ee7442b71b11c7364088fa2
parent 198036 9f20e885fa3a77f0e372fefa3ea2fff515a48f22
child 198110 43c5d06184bba1ac42cd0e7ae5c69d30a34a7bd4
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [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])
   {