From 9ad2475ff40bcb8bf7a79db1d85e85eedad809d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E6=B5=B7?= Date: Tue, 9 May 2023 00:51:13 +0800 Subject: [PATCH] feat: add url-params-cleaner for bilibili-mall --- .../components/utils/url-params-clean/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/registry/lib/components/utils/url-params-clean/index.ts b/registry/lib/components/utils/url-params-clean/index.ts index 9fac4dd99..b4c0d5e4c 100644 --- a/registry/lib/components/utils/url-params-clean/index.ts +++ b/registry/lib/components/utils/url-params-clean/index.ts @@ -49,6 +49,11 @@ const entry = async () => { 'vd_source', 'is_story_h5', 'buvid', + 'goFrom', + 'jumpLinkType', + 'hasBack', + 'noTitleBar', + 'msource', ] const [blockParams] = registerAndGetData('urlParamsClean.params', builtInBlockParams) const builtInSiteSpecifiedParams = [ @@ -72,6 +77,10 @@ const entry = async () => { match: /\/\/www\.bilibili\.com\/video\//, param: 'up_id', }, + { + match: /\/\/mall\.bilibili\.com\//, + param: 'noReffer', + }, ] const [siteSpecifiedParams] = registerAndGetData( 'urlParamsClean.siteSpecifiedParams', @@ -81,7 +90,9 @@ const entry = async () => { const [tailingSlash] = registerAndGetData('urlParamsClean.tailingSlash', builtInTailingSlash) const clean = () => { - const urlParams = window.location.search.substring(1).split('&') + const urlParams = [...new URLSearchParams(window.location.search).entries()].map( + ([key, value]) => `${key}=${value},`, + ) if (urlParams.some(param => noClean.some(it => param.includes(it)))) { return } @@ -124,7 +135,7 @@ export const component = defineComponentMetadata({ entry, description: { 'zh-CN': - '自动删除网址中的多余跟踪参数. 请注意这会导致浏览器历史记录出现重复的标题 (分别是转换前后的网址), 并可能导致后退要多退几次.', + '自动删除网址中的多余跟踪参数。请注意这会导致浏览器历史记录出现重复的标题(分别是转换前后的网址),并可能导致后退要多退几次。', }, tags: [componentsTags.utils], urlExclude: [/game\.bilibili\.com\/fgo/, /live\.bilibili\.com\/p\/html\/live-app-hotrank\//],