Socket
Socket
Sign inDemoInstall

@sanity/state-router

Package Overview
Dependencies
Maintainers
6
Versions
702
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/state-router - npm Package Compare versions

Comparing version 0.3.0-beta.1 to 0.99.0

.travis.yml

2

components.js

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

module.exports = require('./lib/components')
module.exports = require('./lib/components')

@@ -49,4 +49,2 @@ '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);

@@ -63,3 +61,2 @@ }

resolvePathFromState: this.resolvePathFromState,
resolveIntentLink: this.resolveIntentLink,
navigateUrl: this.navigateUrl

@@ -66,0 +63,0 @@ },

@@ -46,3 +46,2 @@ 'use strict';

},
resolveIntentLink: __internalRouter.resolveIntentLink,
navigateUrl: __internalRouter.navigateUrl

@@ -49,0 +48,0 @@ },

@@ -25,4 +25,2 @@ 'use strict';

var _paramsEncoding = require('./utils/paramsEncoding');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -72,24 +70,2 @@

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 = {};

@@ -96,0 +72,0 @@ function isRoot(pathname) {

{
"name": "@sanity/state-router",
"version": "0.3.0-beta.1",
"version": "0.99.0",
"description": "A path pattern => state object bidirectional mapper",

@@ -26,20 +26,7 @@ "main": "lib/index.js",

"devDependencies": {
"babel-cli": "^6.18.0",
"babel-core": "^6.18.2",
"babel-eslint": "^7.1.0",
"babel-plugin-lodash": "^3.2.9",
"babel-plugin-syntax-class-properties": "^6.13.0",
"babel-plugin-syntax-flow": "^6.18.0",
"babel-plugin-syntax-object-rest-spread": "^6.13.0",
"babel-plugin-transform-class-properties": "^6.19.0",
"babel-plugin-transform-flow-strip-types": "^6.18.0",
"babel-plugin-transform-object-rest-spread": "^6.19.0",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-register": "^6.18.0",
"babelify": "^7.3.0",
"browserify": "^13.1.1",
"error-capture-middleware": "0.0.2",
"eslint": "^3.10.2",
"eslint-config-bengler": "^2.0.0",

@@ -46,0 +33,0 @@ "eslint-plugin-import": "^2.2.0",

## @sanity/state-router
[![Build Status](https://travis-ci.org/sanity-io/state-router.svg?branch=master)](https://travis-ci.org/sanity-io/state-router)
## Features

@@ -4,0 +6,0 @@ Based on a routing schema:

@@ -24,6 +24,2 @@ import React, {PropTypes} from 'react'

resolveIntentLink = (intent, params) => {
return this.props.router.encode({intent, params})
}
getChildContext() {

@@ -34,3 +30,2 @@ const {state} = this.props

resolvePathFromState: this.resolvePathFromState,
resolveIntentLink: this.resolveIntentLink,
navigateUrl: this.navigateUrl

@@ -37,0 +32,0 @@ },

@@ -23,3 +23,2 @@ import React, {PropTypes} from 'react'

},
resolveIntentLink: __internalRouter.resolveIntentLink,
navigateUrl: __internalRouter.navigateUrl

@@ -26,0 +25,0 @@ },

@@ -7,3 +7,2 @@ // @flow

import resolvePathFromState from './resolvePathFromState'
import {decodeParams, encodeParams} from './utils/paramsEncoding'

@@ -63,20 +62,2 @@ 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 = {}

@@ -83,0 +64,0 @@ function isRoot(pathname: string): boolean {

// @flow
import test from './_util/test'
import route from '../src/route'
import {decodeParams, encodeParams} from '../src/utils/paramsEncoding'
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(';')
}

@@ -6,0 +18,0 @@ test('transform config on regular routes', t => {

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