[bugzilla-gnome-org-extensions] Make configBugzillaUrl include a trailing /



commit 55e8e7153147bb647dd2e059ff0dfa97b8990fdd
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Thu Oct 15 12:41:10 2009 -0400

    Make configBugzillaUrl include a trailing /
    
    - Expect a trailing slash when building URLs from configBugzillaUrl
    - Make the proxy add a slash to the config URL if missing and
      adjust code for building proxy URLs.
    
    This fixes the "Go to bug" link when running inside Bugzilla to
    be /show_bug.cgi not //show_bug.cgi.

 js/splinter.js          |    2 +-
 proxy/splinter_proxy.py |   10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/js/splinter.js b/js/splinter.js
index 92c3f5c..392b555 100644
--- a/js/splinter.js
+++ b/js/splinter.js
@@ -1053,7 +1053,7 @@ function showChooseAttachment() {
     $("#bugInfo").show();
 
     document.title = "Bug " + theBug.id + " - " + theBug.shortDesc + " - Patch Review";
-    $("#originalBugLink").attr('href', configBugzillaUrl + "/show_bug.cgi?id=" + theBug.id);
+    $("#originalBugLink").attr('href', configBugzillaUrl + "show_bug.cgi?id=" + theBug.id);
 
     $("#allReviewsLink").attr('href', configBase);
 
diff --git a/proxy/splinter_proxy.py b/proxy/splinter_proxy.py
index 7c071ea..2f128f7 100755
--- a/proxy/splinter_proxy.py
+++ b/proxy/splinter_proxy.py
@@ -84,10 +84,12 @@ def get_proxy_info(path):
         portstr = ""
     port = port_from_scheme(split.scheme, split.port)
 
+    proxy_path = split.path + path[1:] # Chop leading / off of path
+
     url = "%s://%s%s%s" % (split.scheme, split.hostname,
-                           portstr, split.path + path)
+                           portstr, proxy_path)
 
-    return split.scheme, split.hostname, port, split.path + path, url
+    return split.scheme, split.hostname, port, proxy_path, url
 
 # Without the mixin, HTTPServer is single-connection-at-a-time
 class ProxyServer(HTTPServer, ForkingMixIn):
@@ -482,6 +484,10 @@ if not config_name in config.configs:
     sys.exit(1)
 
 current_config = config.configs[config_name]
+# Simpler to normalize here than to require the config to have
+# a particular form
+if not current_config['bugzilla_url'].endswith('/'):
+    current_config['bugzilla_url'] += '/'
 
 proxy_scheme, proxy_hostname, proxy_port, proxy_path, proxy_url = get_proxy_info("/xmlrpc.cgi")
 transport = LoginTransport(proxy_scheme, proxy_hostname, proxy_port)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]