You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by jo...@apache.org on 2010/03/24 00:24:55 UTC

svn commit: r926848 - in /shindig/trunk/features/src: main/javascript/features/core.io/io.js test/javascript/features/core.io/iotest.js

Author: johnh
Date: Tue Mar 23 23:24:54 2010
New Revision: 926848

URL: http://svn.apache.org/viewvc?rev=926848&view=rev
Log:
Fully qualify (with scheme) getProxyUrls when config uses schema-relative URLs.


Modified:
    shindig/trunk/features/src/main/javascript/features/core.io/io.js
    shindig/trunk/features/src/test/javascript/features/core.io/iotest.js

Modified: shindig/trunk/features/src/main/javascript/features/core.io/io.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.io/io.js?rev=926848&r1=926847&r2=926848&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.io/io.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.io/io.js Tue Mar 23 23:24:54 2010
@@ -497,13 +497,17 @@ gadgets.io = function() {
 
       var rewriteMimeParam =
           params.rewriteMime ? "&rewriteMime=" + encodeURIComponent(params.rewriteMime) : "";
-      return config.proxyUrl.replace("%url%", encodeURIComponent(url)).
+      var ret = config.proxyUrl.replace("%url%", encodeURIComponent(url)).
           replace("%host%", document.location.host).
           replace("%rawurl%", url).
           replace("%refresh%", encodeURIComponent(refresh)).
           replace("%gadget%", encodeURIComponent(urlParams.url)).
           replace("%container%", encodeURIComponent(urlParams.container || urlParams.synd)).
           replace("%rewriteMime%", rewriteMimeParam);
+      if (ret.indexOf('//') == 0) {
+        ret = window.location.protocol + ret;
+      }
+      return ret;
     }
   };
 }();

Modified: shindig/trunk/features/src/test/javascript/features/core.io/iotest.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/core.io/iotest.js?rev=926848&r1=926847&r2=926848&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/core.io/iotest.js (original)
+++ shindig/trunk/features/src/test/javascript/features/core.io/iotest.js Tue Mar 23 23:24:54 2010
@@ -42,6 +42,13 @@ IoTest.prototype.setUp = function() {
   gadgets.io.preloaded_ = [];
 };
 
+IoTest.prototype.setSchemaless = function() {
+  gadgets.config.init({ "core.io" : {
+      "proxyUrl" : "//example.com/proxy?url=%url%&refresh=%refresh%&g=%gadget%&c=%container%",
+      "jsonProxyUrl" : "http://example.com/json" }});
+  gadgets.io.preloaded_ = [];
+};
+
 IoTest.prototype.tearDown = function() {
   gadgets.util.getUrlParameters = this.oldGetUrlParameters;
   window.XMLHttpRequest = this.oldXMLHTTPRequest;
@@ -79,6 +86,18 @@ IoTest.prototype.testGetProxyUrl_disable
       proxied);
 };
 
+IoTest.prototype.testGetProxyUrl_schemaless = function() {
+  this.setSchemaless();
+  window.location = { protocol: "https:" };
+  var proxied = gadgets.io.getProxyUrl("http://target.example.com/image.gif");
+  this.assertEquals(
+      "https://example.com/proxy?url=http%3a%2f%2ftarget.example.com%2fimage.gif" +
+          "&refresh=3600" +
+          "&g=http%3a%2f%2fwww.gadget.com%2fgadget.xml" +
+          "&c=foo",
+      proxied);
+};
+
 IoTest.prototype.testEncodeValues = function() {
   var x = gadgets.io.encodeValues({ 'foo' : 'bar' });
   this.assertEquals("foo=bar", x);