=rem Wrong and superfluous pattern match in EndpointWriter

I distinctly remember fixing this, it seems this was lost in a rebase round somewhere. Needs to be backported to 2.2