Skip to content

Instantly share code, notes, and snippets.

@sebastibe
Forked from dericcrago/gist:1886177
Last active December 15, 2015 15:08
Show Gist options
  • Save sebastibe/5279233 to your computer and use it in GitHub Desktop.
Save sebastibe/5279233 to your computer and use it in GitHub Desktop.
User = Backbone.Model.extend({
url: function() {
var origUrl = Backbone.Model.prototype.url.call(this);
return origUrl += origUrl.endsWith('/') ? '' : '/';
}
});
@sebastibe
Copy link
Author

To use the endsWith string method, you need the following code:

if (typeof String.prototype.endsWith !== 'function') {
    String.prototype.endsWith = function(suffix) {
        return this.indexOf(suffix, this.length - suffix.length) !== -1;
    };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment