Permalink
Browse files

Merge branch 'master' into internal-bind

  • Loading branch information...
quirkey committed May 25, 2011
2 parents 680d8eb + 65d7f9d commit 06473f3473efe7c764e180617d661009eb94eaff
Showing with 28 additions and 4 deletions.
  1. +4 −0 README.md
  2. +20 −4 lib/sammy.js
  3. +4 −0 test/test_sammy_event_context.js
View
@@ -86,6 +86,10 @@ Sammy.js was created and is maintained by Aaron Quint <aaron at quirkey.com> wit
* dvv
* Ben Vinegar / benvinegar
+## Donate!
+
+If you're using Sammy.js in production or just for fun, instead of gifting me a beer - please consider donating to the [Code for Other People Fund]:http://pledgie.com/campaigns/15239 - you can probably spare a dollar or ten and it will be greatly appreciated.
+
## License
Sammy is covered by the MIT License. See LICENSE for more information.
View
@@ -1881,10 +1881,26 @@
//
redirect: function() {
var to, args = _makeArray(arguments),
- current_location = this.app.getLocation();
- if (args.length > 1) {
- args.unshift('/');
- to = this.join.apply(this, args);
+ current_location = this.app.getLocation(),
+ l = args.length;
+ if (l > 1) {
+ var i = 0, paths = [], params = {}, has_params = false;
+ for (; i < l; i++) {
+ if (typeof args[i] == 'string') {
+ paths.push(args[i]);
+ } else {
+ $.extend(params, args[i]);
+ has_params = true;
+ }
+ }
+ to = paths.join('/');
+ if (has_params) {
+ var pairs = [];
+ for (var k in params) {
+ pairs.push(this.app._encodeFormPair(k, params[k]));
+ }
+ to += '?' + pairs.join('&')
+ }
} else {
to = args[0];
}
@@ -48,6 +48,10 @@
var boosh = 'boosh';
this.context.redirect('#', 'blah', boosh);
equal('#/blah/boosh', window.location.hash);
+ })
+ .should('append to query string if an argument is an object', function() {
+ this.context.redirect('#', 'blah', 'boosh', {x: 'y'}, {a: 'b'});
+ equal(window.location.hash, '#/blah/boosh?x=y&a=b');
});

0 comments on commit 06473f3

Please sign in to comment.