rescript-react icon indicating copy to clipboard operation
rescript-react copied to clipboard

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

Open harshit-juspay opened this issue 4 months ago • 0 comments

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

harshit-juspay avatar Sep 17 '25 07:09 harshit-juspay