0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Fix match_qs with constraints when key is not present

Original fix by Ali Farhadi <a.farhadi@gmail.com>.
This commit is contained in:
geeksilva97 2024-01-18 20:50:27 -03:00 committed by Loïc Hoguin
parent 3e145af9b9
commit 08c2be058a
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
3 changed files with 8 additions and 1 deletions

View file

@ -1024,7 +1024,12 @@ filter([], Map, Errors) ->
_ -> {error, Errors}
end;
filter([{Key, Constraints}|Tail], Map, Errors) ->
filter_constraints(Tail, Map, Errors, Key, maps:get(Key, Map), Constraints);
case maps:find(Key, Map) of
{ok, Value} ->
filter_constraints(Tail, Map, Errors, Key, Value, Constraints);
error ->
filter(Tail, Map, Errors#{Key => required})
end;
filter([{Key, Constraints, Default}|Tail], Map, Errors) ->
case maps:find(Key, Map) of
{ok, Value} ->