From 2b8f116dccc85ae51c856c7851f2bafb57a1023f Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Wed, 20 Mar 2013 11:11:18 +0800 Subject: [PATCH] Adding a test for slashes with splats, github-style --- test/router.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/router.js b/test/router.js index fff5e538..e0c86c2c 100644 --- a/test/router.js +++ b/test/router.js @@ -82,6 +82,7 @@ $(document).ready(function() { "optional(/:item)": "optionalItem", "named/optional/(y:z)": "namedOptional", "splat/*args/end": "splat", + ":repo/compare/*from...*to": "github", "decode/:named/*splat": "decode", "*first/complex-*part/*rest": "complex", ":entity?*args": "query", @@ -127,6 +128,12 @@ $(document).ready(function() { this.args = args; }, + github: function(repo, from, to) { + this.repo = repo; + this.from = from; + this.to = to; + }, + complex: function(first, part, rest) { this.first = first; this.part = part; @@ -238,6 +245,14 @@ $(document).ready(function() { equal(router.args, 'long-list/of/splatted_99args'); }); + test("routes (github)", 3, function() { + location.replace('http://example.com#backbone/compare/1.0...braddunbar:with/slash'); + Backbone.history.checkUrl(); + equal(router.repo, 'backbone'); + equal(router.from, '1.0'); + equal(router.to, 'braddunbar:with/slash'); + }); + test("routes (optional)", 2, function() { location.replace('http://example.com#optional'); Backbone.history.checkUrl();