Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backbone.base-router

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone.base-router - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

2

bower.json
{
"name": "backbone.base-router",
"version": "1.1.0",
"version": "1.2.0",
"homepage": "https://github.com/jmeas/backbone.base-router",

@@ -5,0 +5,0 @@ "authors": [

@@ -1,6 +0,11 @@

### [1.1.0](https://github.com/jmeas/backbone.radio/releases/tag/1.1.0)
### [1.2.0](https://github.com/jmeas/backbone.base-router/releases/tag/1.2.0)
- **New feature:** The `routeData` Object now returns the original query string under `queryString`
- **New feature:** Splat values are now included in `routeData.params`
### [1.1.0](https://github.com/jmeas/backbone.base-router/releases/tag/1.1.0)
- Updated dependencies to include the latest Backbone and Underscore versions.
### [1.0.0](https://github.com/jmeas/backbone.radio/releases/tag/v1.0.0)
### [1.0.0](https://github.com/jmeas/backbone.base-router/releases/tag/v1.0.0)

@@ -10,3 +15,3 @@ - **Enhancement**: Adds support for multiple query parameters of the same name. They

### [0.5.0](https://github.com/jmeas/backbone.radio/releases/tag/v0.5.0)
### [0.5.0](https://github.com/jmeas/backbone.base-router/releases/tag/v0.5.0)

@@ -16,7 +21,7 @@ - Updated Backbone dependency

### [0.4.1](https://github.com/jmeas/backbone.radio/releases/tag/v0.4.1)
### [0.4.1](https://github.com/jmeas/backbone.base-router/releases/tag/v0.4.1)
- **Bug fix**: Uses the constructor on the Router's prototype
### [0.4.0](https://github.com/jmeas/backbone.radio/releases/tag/v0.4.0)
### [0.4.0](https://github.com/jmeas/backbone.base-router/releases/tag/v0.4.0)

@@ -23,0 +28,0 @@ - **Refactor**: No longer override `_routeToRegExp`

@@ -1,2 +0,2 @@

// Backbone.BaseRouter v1.1.0
// Backbone.BaseRouter v1.2.0
(function(root, factory) {

@@ -24,3 +24,3 @@ if (typeof define === 'function' && define.amd) {

// This is copied over from Backbone, because it doesn't expose it
var NAMED_PARAM = /(\(\?)?:\w+/g;
var NAMED_PARAM = /(\(\?)?[:*]\w+/g;
// Find plus symbols

@@ -74,2 +74,3 @@ var PLUS_SYMBOL = /\+/g;

if (navOptions) { routeData.navOptions = navOptions; }
routeData.queryString = queryString ? queryString : undefined;
routeData.query = router._getQueryParameters(queryString);

@@ -76,0 +77,0 @@ routeData.params = router._getNamedParams(routeStr, routeParams);

@@ -1,4 +0,4 @@

// Backbone.BaseRouter v1.1.0
// Backbone.BaseRouter v1.2.0
!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=/(\(\?)?:\w+/g,d=/\+/g;return a.BaseRouter=a.Router.extend({constructor:function(){this.routeParams={},a.Router.prototype.constructor.apply(this,arguments)},onNavigate:function(a){},route:function(d,e){var f,g;b.isRegExp(d)?(f=d,g=""+d):(f=this._routeToRegExp(d),g=d),this.routeParams[d]=b.invoke(g.match(c),"slice",1);var h={route:f,router:this,linked:e};b.isRegExp(d)||(h.originalRoute=d);var i=this;return a.history.route(f,function(a,b){var c=i._extractParameters(f,a),d=c.pop();b&&(h.navOptions=b),h.query=i._getQueryParameters(d),h.params=i._getNamedParams(g,c),h.uriFragment=a,i.onNavigate(h)}),this},_getQueryParameters:function(a){return a?b.reduce(a.split("&"),function(a,c){var e=c.replace(d," ").split("="),f=e[0],g=e[1];return f=decodeURIComponent(f),g=void 0===g?null:decodeURIComponent(g),a[f]?b.isArray(a[f])?a[f].push(g):a[f]=[a[f],g]:a[f]=g,a},{}):{}},_getNamedParams:function(a,c){if(!c.length)return{};var d=this.routeParams[a],e=c.slice(0,d.length);return b.object(b.zip(d,e))}}),a.BaseRouter});
!function(a,b){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(a,c){return b(a,c)});else if("undefined"!=typeof exports){var c=require("backbone"),d=require("underscore");module.exports=b(c,d)}else b(a.Backbone,a._)}(this,function(a,b){"use strict";var c=/(\(\?)?[:*]\w+/g,d=/\+/g;return a.BaseRouter=a.Router.extend({constructor:function(){this.routeParams={},a.Router.prototype.constructor.apply(this,arguments)},onNavigate:function(a){},route:function(d,e){var f,g;b.isRegExp(d)?(f=d,g=""+d):(f=this._routeToRegExp(d),g=d),this.routeParams[d]=b.invoke(g.match(c),"slice",1);var h={route:f,router:this,linked:e};b.isRegExp(d)||(h.originalRoute=d);var i=this;return a.history.route(f,function(a,b){var c=i._extractParameters(f,a),d=c.pop();b&&(h.navOptions=b),h.queryString=d?d:void 0,h.query=i._getQueryParameters(d),h.params=i._getNamedParams(g,c),h.uriFragment=a,i.onNavigate(h)}),this},_getQueryParameters:function(a){return a?b.reduce(a.split("&"),function(a,c){var e=c.replace(d," ").split("="),f=e[0],g=e[1];return f=decodeURIComponent(f),g=void 0===g?null:decodeURIComponent(g),a[f]?b.isArray(a[f])?a[f].push(g):a[f]=[a[f],g]:a[f]=g,a},{}):{}},_getNamedParams:function(a,c){if(!c.length)return{};var d=this.routeParams[a],e=c.slice(0,d.length);return b.object(b.zip(d,e))}}),a.BaseRouter});
//# sourceMappingURL=backbone.base-router.min.js.map
{
"name": "backbone.base-router",
"version": "1.1.0",
"version": "1.2.0",
"description": "A better starting point for a new Backbone Router.",

@@ -5,0 +5,0 @@ "main": "dist/backbone.base-router.js",

@@ -105,2 +105,6 @@ # backbone.base-router

##### `queryString`
The original query string in the URI fragment. `undefined` if no query string given
##### `router`

@@ -107,0 +111,0 @@

@@ -6,3 +6,3 @@ //

// This is copied over from Backbone, because it doesn't expose it
var NAMED_PARAM = /(\(\?)?:\w+/g;
var NAMED_PARAM = /(\(\?)?[:*]\w+/g;
// Find plus symbols

@@ -56,2 +56,3 @@ var PLUS_SYMBOL = /\+/g;

if (navOptions) { routeData.navOptions = navOptions; }
routeData.queryString = queryString ? queryString : undefined;
routeData.query = router._getQueryParameters(queryString);

@@ -58,0 +59,0 @@ routeData.params = router._getNamedParams(routeStr, routeParams);

@@ -16,3 +16,3 @@ describe('Base Router', function() {

Backbone.history.start({pushState: true});
this.regularKeys = ['linked', 'route', 'originalRoute', 'params', 'query', 'router', 'uriFragment'];
this.regularKeys = ['linked', 'route', 'originalRoute', 'params', 'query', 'queryString', 'router', 'uriFragment'];
});

@@ -52,2 +52,6 @@

it('should pass undefined for queryString', function() {
expect(this.routeData.queryString).to.equal(undefined);
});
it('should pass an empty object for named params', function() {

@@ -63,3 +67,3 @@ expect(this.routeData.params).to.deep.equal({});

Backbone.history.start({pushState: false});
this.regularKeys = ['linked', 'route', 'originalRoute', 'params', 'query', 'router', 'uriFragment'];
this.regularKeys = ['linked', 'route', 'originalRoute', 'params', 'query', 'queryString', 'router', 'uriFragment'];
});

@@ -99,2 +103,6 @@

it('should pass undefined for queryString', function() {
expect(this.routeData.queryString).to.equal(undefined);
});
it('should pass an empty object for named params', function() {

@@ -141,2 +149,6 @@ expect(this.routeData.params).to.deep.equal({});

it('should pass undefined for queryString', function() {
expect(this.routeData.queryString).to.equal(undefined);
});
it('should pass the parsed URI params', function() {

@@ -183,2 +195,6 @@ expect(this.routeData.params).to.deep.equal({id: '2', chapter: '4'});

it('should pass undefined for queryString', function() {
expect(this.routeData.queryString).to.equal(undefined);
});
it('should pass the parsed URI params', function() {

@@ -225,2 +241,6 @@ expect(this.routeData.params).to.deep.equal({id: '2', chapter: '4'});

it('should pass the original query string', function() {
expect(this.routeData.queryString).to.equal('james=true&hungry=3');
});
it('should pass an empty object for named params', function() {

@@ -267,2 +287,6 @@ expect(this.routeData.params).to.deep.equal({});

it('should pass the original query string', function() {
expect(this.routeData.queryString).to.equal('james=true&hungry=3');
});
it('should pass an empty object for named params', function() {

@@ -309,2 +333,6 @@ expect(this.routeData.params).to.deep.equal({});

it('should pass the original query string', function() {
expect(this.routeData.queryString).to.equal('letters=a&letters=b&letters=c');
});
it('should pass an empty object for named params', function() {

@@ -351,2 +379,6 @@ expect(this.routeData.params).to.deep.equal({});

it('should pass the original query string', function() {
expect(this.routeData.queryString).to.equal('letters=a&letters=b&letters=c');
});
it('should pass an empty object for named params', function() {

@@ -393,4 +425,8 @@ expect(this.routeData.params).to.deep.equal({});

it('should pass undefined for queryString', function() {
expect(this.routeData.queryString).to.equal(undefined);
});
it('should pass the parsed named param', function() {
expect(this.routeData.params).to.deep.equal({id: '3'});
expect(this.routeData.params).to.deep.equal({id: '3', splat: 'deeply/nested/splat'});
});

@@ -435,4 +471,8 @@ });

it('should pass undefined for queryString', function() {
expect(this.routeData.queryString).to.equal(undefined);
});
it('should pass the parsed named param', function() {
expect(this.routeData.params).to.deep.equal({id: '3'});
expect(this.routeData.params).to.deep.equal({id: '3', splat: 'deeply/nested/splat'});
});

@@ -476,4 +516,8 @@ });

it('should pass the original query string', function() {
expect(this.routeData.queryString).to.equal('name=james');
});
it('should pass an empty object for the named params', function() {
expect(this.routeData.params).to.deep.equal({});
expect(this.routeData.params).to.deep.equal({splat: 'deeply/nested/splat'});
});

@@ -517,4 +561,8 @@ });

it('should pass the original query string', function() {
expect(this.routeData.queryString).to.equal('name=james');
});
it('should pass an empty object for the named params', function() {
expect(this.routeData.params).to.deep.equal({});
expect(this.routeData.params).to.deep.equal({splat: 'deeply/nested/splat'});
});

@@ -559,2 +607,6 @@ });

it('should pass undefined for queryString', function() {
expect(this.routeData.queryString).to.equal(undefined);
});
it('should pass empty named params', function() {

@@ -601,2 +653,6 @@ expect(this.routeData.params).to.deep.equal({});

it('should pass undefined for queryString', function() {
expect(this.routeData.queryString).to.equal(undefined);
});
it('should pass empty named params', function() {

@@ -603,0 +659,0 @@ expect(this.routeData.params).to.deep.equal({});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc