AddQueryParam and AddHashParam don't work with ietf rfc

Couple of HttpUtil issues.


HttpUtils.AddQueryParam doesn’t work with hash params. The hash fragment should be at the end of the url according to

If a hash param exists the query param should go before it.

Here are some tests:

Assert.That("".AddQueryParam("f", "2"), Is.EqualTo(""));
Assert.That("#hash".AddQueryParam("a", "b"), Is.EqualTo("?a=b#hash"));
Assert.That("/#hash".AddQueryParam("a", "b"), Is.EqualTo("/?a=b#hash"));
Assert.That("?#hash".AddQueryParam("a", "b"), Is.EqualTo("?a=b#hash"));


The hash fragment, when used for anchor bookmarks can have a null/empty value without the =, e.g. #bookmark.

So not sure if you want a different named extension method instead of AddHashParam or change AddHashParam to work with null/empty param values (which means removing some existing nunit tests).

Here are some tests for the hash fragment:

// This tests that a null value enters the key without the "="
Assert.That("".AddHashParam("#hash", null), Is.EqualTo(""));

// This tests to see if the HashParam is missing the `#` prefix and if so add it.
Assert.That("".AddHashParam("hash", null), Is.EqualTo(""));

AddQueryParam and AddHashParam only appends to the URL, it doesn’t replace or insert contents, you can use SetHashParam to replace existing params. For your valueless #hash param, just append it to the URL yourself where it’s more readable as I don’t want to change existing behavior, esp. for that which has been defined by unit tests.