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

deef-router

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deef-router - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

15

lib/index.js

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

var COMPARE_MATCH_KEYS = ['path', 'params', 'url', 'pathname', 'search'];
var ruleList = [];

@@ -40,3 +41,3 @@

_ref$compareMatchKeys = _ref.compareMatchKeys,
compareMatchKeys = _ref$compareMatchKeys === undefined ? ['path', 'params', 'url'] : _ref$compareMatchKeys;
compareMatchKeys = _ref$compareMatchKeys === undefined ? COMPARE_MATCH_KEYS : _ref$compareMatchKeys;
return function (rule, _ref2, key) {

@@ -121,4 +122,4 @@ var onMatch = _ref2.onMatch,

var ret = {
path: rule.pathname,
params: {}
pathname: rule.pathname,
search: {}
};

@@ -136,3 +137,3 @@ if (rule.pathname && rule.pathname !== location.pathname) {

}
ret.params[key] = searchParams[key];
ret.search[key] = searchParams[key];
return true;

@@ -164,4 +165,6 @@ }) || (ret = null);

function getSearchKey(val) {
return val && '?' + ((0, _isString2.default)(val) ? val.replace(/(^\?|&$)/g, '') : Object.keys(val).join('&'));
function getSearchKey(search) {
return search && '?' + ((0, _isString2.default)(search) ? search.replace(/(^\?|&$)/g, '') : Object.keys(search).map(function (key) {
return (0, _isString2.default)(search[key]) ? key + '=' + search[key] : key;
}).join('&'));
}

2

package.json
{
"name": "deef-router",
"version": "0.1.0",
"version": "0.1.1",
"description": "deef router",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -11,5 +11,6 @@ /**

const COMPARE_MATCH_KEYS = ['path', 'params', 'url', 'pathname', 'search'];
const ruleList = [];
const on = ({history, compareMatchKeys = ['path', 'params', 'url']}) => (rule, {onMatch, onBreakMatch}, key) => {
const on = ({history, compareMatchKeys = COMPARE_MATCH_KEYS}) => (rule, {onMatch, onBreakMatch}, key) => {
// 一个rule只生效一次

@@ -83,4 +84,4 @@ let ruleKey = isString(key) && key;

let ret = {
path: rule.pathname,
params: {}
pathname: rule.pathname,
search: {}
};

@@ -99,3 +100,3 @@ if (rule.pathname && rule.pathname !== location.pathname) {

}
ret.params[key] = searchParams[key];
ret.search[key] = searchParams[key];
return true;

@@ -123,8 +124,8 @@ }) || (ret = null);

function getSearchKey(val) {
return val && '?' + (
isString(val)
? val.replace(/(^\?|&$)/g, '')
: Object.keys(val).join('&')
function getSearchKey(search) {
return search && '?' + (
isString(search)
? search.replace(/(^\?|&$)/g, '')
: Object.keys(search).map(key => isString(search[key]) ? `${key}=${search[key]}` : key).join('&')
);
}
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