mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 12:52:27 +03:00
Fix ordering for ApiRoute matches.
This commit is contained in:
parent
4e755be53e
commit
a39c53de8b
@ -66,6 +66,7 @@ pathToMatches path (ApiRouteBuilder _ pattern _ _ _) =
|
||||
path
|
||||
|> List.concatMap .submatches
|
||||
|> List.filterMap identity
|
||||
|> List.reverse
|
||||
|
||||
|
||||
{-| -}
|
||||
@ -88,6 +89,7 @@ tryMatch path (ApiRouteBuilder _ pattern handler _ _) =
|
||||
path
|
||||
|> List.concatMap .submatches
|
||||
|> List.filterMap identity
|
||||
|> List.reverse
|
||||
in
|
||||
handler matches
|
||||
|> Just
|
||||
|
@ -76,6 +76,38 @@ all =
|
||||
[ "users/100.json"
|
||||
, "users/101.json"
|
||||
]
|
||||
, test "matches with two dynamic segments" <|
|
||||
\() ->
|
||||
succeed
|
||||
(\author name ->
|
||||
author ++ " - " ++ name
|
||||
)
|
||||
|> literal "package"
|
||||
|> slash
|
||||
|> capture
|
||||
|> slash
|
||||
|> capture
|
||||
|> tryMatch "package/dillonkearns/elm-pages"
|
||||
|> Expect.equal (Just "dillonkearns - elm-pages")
|
||||
, test "routes with two dynamic segments" <|
|
||||
\() ->
|
||||
succeed
|
||||
(\author name ->
|
||||
author ++ " - " ++ name
|
||||
)
|
||||
|> literal "package"
|
||||
|> slash
|
||||
|> capture
|
||||
|> slash
|
||||
|> capture
|
||||
|> withRoutes
|
||||
(\constructor ->
|
||||
[ constructor "dillonkearns" "elm-pages"
|
||||
]
|
||||
)
|
||||
|> Expect.equal
|
||||
[ "package/dillonkearns/elm-pages"
|
||||
]
|
||||
, describe "toPattern"
|
||||
[ test "no dynamic segments" <|
|
||||
\() ->
|
||||
|
Loading…
Reference in New Issue
Block a user