Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Using a save join() for the default implementation of Model#url

  • Loading branch information...
commit 11dcf246c70e5a53b6c6789b310875482e0f4645 1 parent 99fbc08
@jashkenas authored
Showing with 3 additions and 1 deletion.
  1. +1 −1  backbone.js
  2. +2 −0  test/model.js
View
2  backbone.js
@@ -274,7 +274,7 @@
url : function() {
var base = getUrl(this.collection);
if (this.isNew()) return base;
- return base + '/' + this.id;
+ return base + (base.charAt(base.length - 1) == '/' ? '' : '/') + this.id;
},
// **parse** converts a response into the hash of attributes to be `set` on
View
2  test/model.js
@@ -53,6 +53,8 @@ $(document).ready(function() {
test("Model: url", function() {
equals(doc.url(), '/collection/1-the-tempest');
+ doc.collection.url = '/collection/';
+ equals(doc.url(), '/collection/1-the-tempest');
doc.collection = null;
var failed = false;
try {
Please sign in to comment.
Something went wrong with that request. Please try again.