include trailing ? or & when the query is not null but empty

Signed-off-by: Marc Lefrançois <mlefrancois@mirego.com>