Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:developmentseed/bones

  • Loading branch information...
commit a7058299f0923f97b94c8c9f50ee3b6b57792b0f 2 parents cadb1b1 + eeb94ad
@miccolis miccolis authored
View
2  server/router.js
@@ -53,7 +53,7 @@ Backbone.Router.prototype.route = function(route, name, callback) {
// Add route to express server.
var router = this;
this.server.get(route, function(req, res, next) {
- var fragment = (req.query && req.query['_escaped_fragment_']) || req.url;
+ var fragment = (req.query && req.query['_escaped_fragment_']) || req.url.replace(/[#?].*$/, '');
var args = router._extractParameters(route, fragment);
var context = Object.create(router, { req: { value: req }, res: { value: res } });
callback.apply(context, args);
View
7 test/fixture/routers/Page.bones
@@ -1,5 +1,6 @@
router = Backbone.Router.extend({
routes: {
+ '/': 'home',
'/page/:id': 'page',
'/page/special': 'pageSpecial'
},
@@ -7,8 +8,12 @@ router = Backbone.Router.extend({
page: function(id) {
this.res && this.res.send('page ' + id);
},
-
+
pageSpecial: function() {
this.res && this.res.send('special page');
+ },
+
+ home: function() {
+ this.res && this.res.send('home');
}
});
View
34 test/urls.test.js
@@ -0,0 +1,34 @@
+process.env.NODE_ENV = 'test';
+var assert = require('assert');
+
+var server = require('./fixture/start').servers.Core;
+
+exports['_escaped_fragment_ redirect'] = function() {
+ assert.response(server, {
+ url: '/page/special?_escaped_fragment_=/something/different',
+ method: 'GET'
+ }, {
+ body: '<p>Moved Permanently. Redirecting to <a href="http://127.0.0.1:3000/something/different">http://127.0.0.1:3000/something/different</a></p>',
+ status: 301
+ });
+}
+
+exports['hash request'] = function() {
+ assert.response(server, {
+ url: '/#!/map/devseed-hq',
+ method: 'GET'
+ }, {
+ body: 'home',
+ status: 200
+ });
+}
+
+exports['query request'] = function() {
+ assert.response(server, {
+ url: '/?foo',
+ method: 'GET'
+ }, {
+ body: 'home',
+ status: 200
+ });
+}
Please sign in to comment.
Something went wrong with that request. Please try again.