UNPKG

use-url-sync

Version:

use-url-sync is a utility package that helps you sync your states to url without hassle

17 lines (16 loc) 645 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); /* eslint-disable @typescript-eslint/no-explicit-any */ const qs_1 = __importDefault(require("qs")); const getUrlString = (states) => { const { pathname } = window.location; if (typeof states !== 'object') return pathname; const queryUrl = qs_1.default.stringify(states); const parsed = `${pathname}${queryUrl ? `?${queryUrl}` : ''}`; return parsed; }; exports.default = getUrlString;