Handle index special case in new routeToPath.

This commit is contained in:
Dillon Kearns 2021-04-28 13:42:47 -07:00
parent da4482f0f2
commit 4673565123
2 changed files with 4 additions and 2 deletions

View File

@ -539,7 +539,9 @@ routeToPath maybeRoute =
.map((param) => {
switch (param.kind) {
case "static": {
return `[ "${camelToKebab(param.name)}" ]`;
return param.name === "Index"
? `[]`
: `[ "${camelToKebab(param.name)}" ]`;
}
case "optional": {
return `Router.maybeToList params.${param.name}`;

View File

@ -95,7 +95,7 @@ ensureLeadingSlash path =
stripTrailingSlash : String -> String
stripTrailingSlash path =
if path |> String.endsWith "/" then
if (path |> String.endsWith "/") && (String.length path > 1) then
String.dropRight 1 path
else