Permalink
Browse files

Updated Jester to handle file:// domains, and fix a bug with assuming…

… https:// domains. Thanks to Jack Christensen for finding this.

git-svn-id: https://svn.thoughtbot.com/jester/trunk@118 d7758119-aa2c-0410-afcd-b700fbd0d0b3
  • Loading branch information...
emill
emill committed Jan 10, 2008
1 parent 85e6e1e commit cbb6293d797db4fe778a2bbed164f5912179db20
Showing with 6 additions and 5 deletions.
  1. +4 −3 jester.js
  2. +2 −2 test/jester_test.html
View
@@ -50,14 +50,14 @@ Object.extend(Jester.Resource, {
options.remote = false;
// Establish prefix
- var default_prefix = "http://" + window.location.hostname + (window.location.port ? ":" + window.location.port : "")
+ var default_prefix = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
if (options.prefix && options.prefix.match(/^https?:/))
options.remote = true;
if (!options.prefix)
options.prefix = default_prefix;
- if (!options.prefix.match(/^https?:/))
+ if (!options.prefix.match(/^(https?|file):/))
options.prefix = default_prefix + (options.prefix.match(/^\//) ? "" : "/") + options.prefix;
options.prefix = options.prefix.replace(/\b\/+$/,"");
@@ -744,7 +744,8 @@ function bind(context, func) {
// If there is no object already called Resource, we define one to make things a little cleaner for us.
if(typeof(Resource) == "undefined")
- Resource = Jester.Resource
+ Resource = Jester.Resource;
+
View
@@ -15,7 +15,7 @@
<script language="JavaScript" type="text/javascript">
function setUp () {
- default_prefix = function() {return "http://" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");}
+ default_prefix = function() {return window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");}
ericXML = '<?xml version="1.0" encoding="UTF-8"?><user><created-at type="datetime">2007-04-08T15:12:06-04:00</created-at><id type="integer">1</id><first-name>eric</first-name><admin type="boolean">true</admin></user>'
camelCaseXML = '<?xml version="1.0" encoding="UTF-8"?><cool-thing><created-at type="datetime">2007-04-08T15:12:06-04:00</created-at><id type="integer">1</id><first-name>eric</first-name><admin type="boolean">true</admin></cool-thing>'
@@ -365,7 +365,7 @@
var eric = User.find(1);
assertEquals("posts", eric._associations[0]);
assertEquals(Post, eric.posts[0].class);
- assertEquals(original_url, Post._show_url());
+ assertEquals("Auto-generated Post class should have same values as the original one.", original_url, Post._show_url());
assertEquals("post", Post._singular);
assertEquals(User._format, Post._format);
assertEquals(User._prefix, Post._prefix);

0 comments on commit cbb6293

Please sign in to comment.