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

hook-use-url

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hook-use-url - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

29

index.js

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

import {push, replace} from 'connected-react-router';
import {useSelector} from 'react-redux';
import {useDispatch} from 'react-redux';
import {push, replace} from "connected-react-router";
import {useSelector} from "react-redux";
import {useDispatch} from "react-redux";
const queryString = require('query-string');
const queryString = require("query-string");
function pushNewState({dispatch, routerState, allVariables, doReturnUrl, path, doReplaceInsteadPush}) {
const replaceOrPush = doReplaceInsteadPush ? 'replace' : 'push';
const replaceOrPush = doReplaceInsteadPush ? "replace" : "push";
const pathname = typeof path === 'string' ? path
const pathname = typeof path === "string" ? path
: routerState && routerState.location && routerState.location.pathname
? routerState.location.pathname
: '';
: "";
const hash = routerState && routerState.location && routerState.location.hash
? routerState.location.hash
: '';
: "";
const search = queryString.stringify(allVariables);
const url = `${pathname}${search ? `?${search}` : ''}${hash}`;
const url = `${pathname}${search ? `?${search}` : ""}${hash}`;

@@ -25,6 +25,6 @@ if (doReturnUrl === true) {

}
if (replaceOrPush === 'push') {
if (replaceOrPush === "push") {
return dispatch(push(url));
}
if (replaceOrPush === 'replace') {
if (replaceOrPush === "replace") {
return dispatch(replace(url));

@@ -40,3 +40,3 @@ }

? routerState.location.search
: '';
: "";
const allVariables = queryString.parse(search);

@@ -47,3 +47,3 @@ const url = {

let values = url.get({variable}) || [];
if (typeof values === 'string') {
if (typeof values === "string") {
if (values) {

@@ -97,6 +97,6 @@ values = [values];

let newVariables = {...allVariables};
let values = url.arrayGet({variable: pair.variable});
if (arrayAddPairs && arrayAddPairs.length > 0) {
arrayAddPairs.forEach((pair) => {
let values = url.arrayGet({variable: pair.variable});
if (values.includes(pair.value) === false) {

@@ -112,3 +112,2 @@ values.push(pair.value);

arrayRemovePairs.forEach((pair) => {
let values = url.arrayGet({variable: pair.variable});
if (values.includes(pair.value)) {

@@ -115,0 +114,0 @@ values = values.filter((x) => x !== pair.value);

{
"name": "hook-use-url",
"version": "1.0.8",
"version": "1.0.9",
"description": "useUrl hook for easier URL reading & writing within ReactJS app",

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

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