[KSS-checkins] r51463 - kukit/kukit.js/trunk/kukit

jvloothuis at codespeak.net jvloothuis at codespeak.net
Wed Feb 13 21:52:19 CET 2008


Author: jvloothuis
Date: Wed Feb 13 21:52:18 2008
New Revision: 51463

Modified:
   kukit/kukit.js/trunk/kukit/serveraction.js
Log:

Url's starting with a / (like /update_something) are now also
considered to be absolute url's.

Absolute url's also get the `/` appended to them if the don't have
that already. So there is no difference any more between relative and
absolute url's in that regard.


Modified: kukit/kukit.js/trunk/kukit/serveraction.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/serveraction.js	(original)
+++ kukit/kukit.js/trunk/kukit/serveraction.js	Wed Feb 13 21:52:18 2008
@@ -31,6 +31,12 @@
     }
 
     this.calculateAbsoluteURL = function(url) {
+        // Append slash to the end of the url, this helps with certain
+        // webframeworks like Django
+        if (!url.match(RegExp('\/$'))) {
+            url += '/';
+        }
+
         //
         // If the url is an absolute path, it is used
         //
@@ -42,7 +48,7 @@
         //
         //     result='http://your.site.com/portal/folder/object/@@theview/getName'
         //
-        if (url.match(RegExp('/^https?:\/\//'))) {
+        if (url.match(RegExp('/^https?:\/\//')) || url.match(RegExp('^\/'))) {
             return url;
         } 
 
@@ -50,13 +56,8 @@
         if (!result.match(RegExp('\/$'))) {
             result += '/';
         }
-        result += url;
-        // Append slash to the end of the url, this helps with certain
-        // webframeworks like Django
-        if (!result.match(RegExp('\/$'))) {
-            result += '/';
-        }
-        return result;
+
+        return result + url;
     };
     this.url = this.calculateAbsoluteURL(this.url);
     this.notifyServer();


More information about the Kukit-checkins mailing list