tmenier / Flurl

Fluent URL builder and testable HTTP client for .NET
https://flurl.dev
MIT License
4.23k stars 387 forks source link

A way to preserve host casing? #792

Closed MihaMarkic closed 11 months ago

MihaMarkic commented 11 months ago

Is there a way to preserve letter casing with Flurl's URL parsing? Currently it would always lowercase Host.

Input: var url = Url.Parse("https://SomeThing.com/Path")

Output using url.ToString()

Actual: https://something.com/Path

Expected: https://SomeThing.com/Path

Related stack overflow question.

tmenier commented 11 months ago

For Host, the short answer is no. Flurl leverages System.Uri for some aspects of its parsing, and that class normalizes the passed string to its canonical form, which includes lower-casing the scheme and host.

tmenier commented 11 months ago

You can re-open this as a feature request if you want. I just wanted to explain how it works today. Admittedly, it was never intentional behavior and Flurl generally has the philosophy of don't mess with the original string. So I would entertain it if there are legitimate use cases.