rescript-lang / rescript-lang/rescript-react

The pathParse function in RescriptReactRouter.res currently treats single slash and double slash URLs identically, which causes routing conflicts and prevents proper URL differentiation.

未关闭 适合新手
#145 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
ReScript
星标
517
派生
45
PR 合并指标
30 天内没有已合并 PR

描述

Current Behavior

// Both URLs return the same parsed result
pathParse("/analytics-transaction") → list{"analytics-transaction"}
pathParse("//analytics-transaction") → list{"analytics-transaction"} // Problem!

Expected Behavior

// URLs should parse differently to enable proper routing
pathParse("/analytics-transaction") → list{"analytics-transaction"}
pathParse("//analytics-transaction") → list{"", "analytics-transaction"} // Should preserve leading empty string

Impact

  • Cannot differentiate between /path and //path in routing logic
  • Causes "Page Not Found" errors for valid double slash URLs
  • Breaks routing patterns that rely on double slash prefixes

Proposed Solution

Modify the filter logic to preserve the first empty string while removing others:
// Current problematic code
raw->Js.String2.split("/")->Js.Array2.filter(item => item->Js.String2.length != 0)->arrayToList

// Proposed fix
let splitArray = raw->Js.String2.split("/")
let filteredArray = []
splitArray->Js.Array2.forEachi((item, index) => {
if item->Js.String2.length != 0 || index == 0 {
filteredArray->Js.Array2.push(item)->ignore
}
})
filteredArray->arrayToList

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 RescriptReactRouter.res 中的 pathParse 函数开始,检查针对以斜杠分隔的路径的 split 和 filter 逻辑。验证 /analytics-transaction 和 //analytics-transaction 的行为,然后确认结果列表仅对双斜杠 URL 保留开头的空分段。

由索引模型根据 Issue 内容生成。

评估

技术栈
react
领域
frontend
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
描述清楚
新手友好度
65/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。