@sanity/state-router
Advanced tools
Comparing version 0.99.0 to 0.99.4
@@ -1,1 +0,1 @@ | ||
module.exports = require('./lib/components') | ||
module.exports = require('./lib/components') |
@@ -49,2 +49,4 @@ 'use strict'; | ||
return _this.props.router.encode(state); | ||
}, _this.resolveIntentLink = function (intent, params) { | ||
return _this.props.router.encode({ intent: intent, params: params }); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
@@ -61,2 +63,3 @@ } | ||
resolvePathFromState: this.resolvePathFromState, | ||
resolveIntentLink: this.resolveIntentLink, | ||
navigateUrl: this.navigateUrl | ||
@@ -63,0 +66,0 @@ }, |
@@ -46,2 +46,3 @@ 'use strict'; | ||
}, | ||
resolveIntentLink: __internalRouter.resolveIntentLink, | ||
navigateUrl: __internalRouter.navigateUrl | ||
@@ -48,0 +49,0 @@ }, |
@@ -25,2 +25,4 @@ 'use strict'; | ||
var _paramsEncoding = require('./utils/paramsEncoding'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -70,2 +72,24 @@ | ||
function normalize() { | ||
for (var _len2 = arguments.length, paths = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
paths[_key2] = arguments[_key2]; | ||
} | ||
return paths.reduce(function (acc, path) { | ||
return acc.concat(path.split('/')); | ||
}, []).filter(Boolean); | ||
} | ||
route.intents = function intents(base) { | ||
var basePath = normalize(base).join('/'); | ||
return route(basePath + '/:intent', [route(':params', { | ||
transform: { | ||
params: { | ||
toState: _paramsEncoding.decodeParams, | ||
toPath: _paramsEncoding.encodeParams | ||
} | ||
} | ||
})]); | ||
}; | ||
var EMPTY_STATE = {}; | ||
@@ -72,0 +96,0 @@ function isRoot(pathname) { |
{ | ||
"name": "@sanity/state-router", | ||
"version": "0.99.0", | ||
"version": "0.99.4", | ||
"description": "A path pattern => state object bidirectional mapper", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -24,2 +24,6 @@ import React, {PropTypes} from 'react' | ||
resolveIntentLink = (intent, params) => { | ||
return this.props.router.encode({intent, params}) | ||
} | ||
getChildContext() { | ||
@@ -30,2 +34,3 @@ const {state} = this.props | ||
resolvePathFromState: this.resolvePathFromState, | ||
resolveIntentLink: this.resolveIntentLink, | ||
navigateUrl: this.navigateUrl | ||
@@ -32,0 +37,0 @@ }, |
@@ -23,2 +23,3 @@ import React, {PropTypes} from 'react' | ||
}, | ||
resolveIntentLink: __internalRouter.resolveIntentLink, | ||
navigateUrl: __internalRouter.navigateUrl | ||
@@ -25,0 +26,0 @@ }, |
@@ -7,2 +7,3 @@ // @flow | ||
import resolvePathFromState from './resolvePathFromState' | ||
import {decodeParams, encodeParams} from './utils/paramsEncoding' | ||
@@ -62,2 +63,20 @@ type NodeOptions = { | ||
function normalize(...paths) { | ||
return paths | ||
.reduce((acc, path) => acc.concat(path.split('/')), []) | ||
.filter(Boolean) | ||
} | ||
route.intents = function intents(base) { | ||
const basePath = normalize(base).join('/') | ||
return route(`${basePath}/:intent`, [route(':params', { | ||
transform: { | ||
params: { | ||
toState: decodeParams, | ||
toPath: encodeParams | ||
} | ||
} | ||
})]) | ||
} | ||
const EMPTY_STATE = {} | ||
@@ -64,0 +83,0 @@ function isRoot(pathname: string): boolean { |
// @flow | ||
import test from './_util/test' | ||
import route from '../src/route' | ||
function decodeParams(pathsegment) { | ||
return pathsegment.split(';') | ||
.reduce((params, pair) => { | ||
const [key, value] = pair.split('=') | ||
params[key] = value | ||
return params | ||
}, {}) | ||
} | ||
function encodeParams(params) { | ||
return Object.keys(params) | ||
.map(key => `${key}=${params[key]}`) | ||
.join(';') | ||
} | ||
import {decodeParams, encodeParams} from '../src/utils/paramsEncoding' | ||
@@ -18,0 +6,0 @@ test('transform config on regular routes', t => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
235802
67
2000
0