Confusing UriHelper method names #573
Description
Sorry, I find this helper class a bit confusing.
Why is a method that does more than encoding called Encode
? It not only encodes it also combines several uri parts into an uri. And why are two methods called Encode
when one creates an absolute path and the other creates an absolute uri? Why is the unescaped version called so differently (GetDisplayUrl
)? Why is the convenience method GetEncodedUrl
named this way although it does exactly the same as the Encode
method? Only difference is that it is an extension method for HttpRequest
. Why is there no convenience method for the non-absolute version?
Maybe I just don't get it but here is my proposal:
Why not just have two method names GetAbsolutePath
and GetUrl
? Then give those two methods an encode
or httpEncode
or encodeComponents
bool parameter so there is no need for any Display
methods. Then make overloads of both methods that act as convenience methods for HttpRequest
.
So we would get
string GetAbsolutePath(PathString pathBase, PathString path, QueryString query, FragmentString fragment, bool encodeComponents)
gives /foo/bar
Note that this would conform to RFC 3986
A relative reference that begins with a single slash character is
termed an absolute-path reference. A relative reference that does
not begin with a slash character is termed a relative-path reference.
string GetUrl(string scheme, HostString host, PathString pathBase, PathString path, QueryString query, FragmentString fragment, bool encodeComponents)
gives http://example.com/foo/bar