Skip to content

fix: 修复URL query 被逗号拆分导致目标页参数不完整的问题#2475

Open
dos1in wants to merge 2 commits intodidi:masterfrom
dos1in:fix/parse-query
Open

fix: 修复URL query 被逗号拆分导致目标页参数不完整的问题#2475
dos1in wants to merge 2 commits intodidi:masterfrom
dos1in:fix/parse-query

Conversation

@dos1in
Copy link
Copy Markdown
Member

@dos1in dos1in commented Apr 30, 2026

问题描述

H5 页面调用:

wx.miniProgram.navigateTo({
url: '/pages/detail?data=' + JSON.stringify(data)
})

在 RN 下会进入 web-view 的消息处理,再调用 RN 路由的 navigateTo。

RN 路由解析 URL 时走:

packages/api-proxy/src/platform/api/route/index.ios.js (line 46)

const { path, queryObj } = parseUrl(options.url, true)

noDecode=true 等于不做 decodeURIComponent,但后续仍会走 parseQuery 拆 query。

在 packages/utils/src/url.js (line 100) 原逻辑:

const queryArgs = query.split(/[,&]/g)

它会同时按 &, 拆参数。

之前传入的 JSON.stringify(data) 生成的 JSON 里就会包含逗号,比如:

?data={"a":1,"b":2}

会被拆成:

data={"a":1
"b":2}

导致目标页拿到的 query.data 在 JSON.parse(query.data) 时报错。


修复方案

当前修复方式是noDecode=true的情况下不应再把,当 query 分隔符。

另外补充了该问题场景下的相应的测试用例。

@dos1in dos1in marked this pull request as draft April 30, 2026 06:31
@dos1in dos1in marked this pull request as ready for review April 30, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant