From 0726a2176b50801962a5f4b4e2952036e57b9361 Mon Sep 17 00:00:00 2001 From: Gavin Date: Sun, 15 Oct 2023 11:05:18 +0800 Subject: [PATCH] fix: fix types --- src/getUrlAllParams.ts | 4 ++-- src/getUrlParams.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/getUrlAllParams.ts b/src/getUrlAllParams.ts index e38caec..b4dff02 100644 --- a/src/getUrlAllParams.ts +++ b/src/getUrlAllParams.ts @@ -5,8 +5,8 @@ import type { TObject } from './types' * @param url 指定url,默认 location.href */ -export function getUrlAllParams(url: string) { - url = url ? url : window.location.href +export function getUrlAllParams(url?: string) { + url = url ? url : decodeURIComponent(window.location.href) const pa = url.slice(Math.max(0, url.indexOf('?') + 1)), arr = pa.split('&'), result: TObject = {} diff --git a/src/getUrlParams.ts b/src/getUrlParams.ts index 38b021f..f4bf0c7 100644 --- a/src/getUrlParams.ts +++ b/src/getUrlParams.ts @@ -4,7 +4,7 @@ * @param url 指定url,默认 location.href */ -export function getUrlParams(name: string, url: string) { +export function getUrlParams(name: string, url?: string) { const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`) let result = null