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.
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- ReScript
- Star
- 517
- Fork
- 45
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu trong RescriptReactRouter.res, tại hàm pathParse, và kiểm tra logic split và filter đối với các đường dẫn được phân tách bằng dấu gạch chéo. Xác minh hành vi của /analytics-transaction và //analytics-transaction, sau đó xác nhận rằng các danh sách kết quả chỉ giữ lại phân đoạn rỗng ở đầu đối với URL có dấu gạch chéo kép.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- react
- Lĩnh vực
- frontend
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 65/100