From 81e660877eca2a92ef9cccddb3fbff61f20bc160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8F=B2=E9=B8=BD?= <1020103647@qq.com> Date: Tue, 11 Jun 2024 13:29:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(utils):=20getUrlObj=20=E5=81=A5=E5=A3=AE?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 14ef106..f416727 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -50,12 +50,18 @@ const ensureDecodeURIComponent = (url: string) => { */ export const getUrlObj = (url: string) => { const [path, queryStr] = url.split('?') - console.log(path, queryStr) + // console.log(path, queryStr) + if (!queryStr) { + return { + path, + query: {}, + } + } const query: Record = {} queryStr.split('&').forEach((item) => { const [key, value] = item.split('=') - console.log(key, value) + // console.log(key, value) query[key] = ensureDecodeURIComponent(value) // 这里需要统一 decodeURIComponent 一下,可以兼容h5和微信y }) return { path, query }