Skip to content

Commit

Permalink
headers-remove: fix the bug
Browse files Browse the repository at this point in the history
In the case that the name does not match the needle, propagate the
curent value of `seen` rather than passing false.
  • Loading branch information
seliopou committed Oct 3, 2019
1 parent 49682dd commit c0c1935
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/headers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ let replace t name value =
with Local -> t

let remove t name =
let rec loop s n seen =
let rec loop s needle seen =
match s with
| [] ->
if not seen then raise Local else []
| (n',_ as nv')::s' ->
if CI.equal n n' then loop s' n true else nv'::(loop s' n false)
| (name,_ as nv')::s' ->
if CI.equal needle name
then (print_endline "seen: true"; loop s' needle true )
else (print_endline "seen: false"; nv'::(loop s' needle seen))
in
try loop t name false
with Local -> t
Expand Down

0 comments on commit c0c1935

Please sign in to comment.