Path.Combine for URLs?
Path.Combine for URLs?
Path.Combine for URLs?
Re: Path.Combine for URLs?
There [is a Todd Menier's comment above](https://stackoverflow.com/questions/372865/path-combine-for-urls/43582421#comment33212350_372865) that [Flurl](https://flurl.dev/) includes a `Url.Combine`.
More details:
Url.Combine is basically a Path.Combine for URLs, ensuring one
and only one separator character between parts:
```
var url = Url.Combine(
"http://MyUrl.com/",
"/too/", "/many/", "/slashes/",
"too", "few?",
"x=1", "y=2"
// result: "http://www.MyUrl.com/too/many/slashes/too/few?x=1&y=2"
```
Get [Flurl.Http on NuGet](https://www.nuget.org/packages/Flurl.Http/):
PM> Install-Package Flurl.Http
Or [get the stand-alone URL builder](https://www.nuget.org/packages/Flurl/) without the HTTP features:
PM> Install-Package Flurl
More details:
Url.Combine is basically a Path.Combine for URLs, ensuring one
and only one separator character between parts:
```
var url = Url.Combine(
"http://MyUrl.com/",
"/too/", "/many/", "/slashes/",
"too", "few?",
"x=1", "y=2"
// result: "http://www.MyUrl.com/too/many/slashes/too/few?x=1&y=2"
```
Get [Flurl.Http on NuGet](https://www.nuget.org/packages/Flurl.Http/):
PM> Install-Package Flurl.Http
Or [get the stand-alone URL builder](https://www.nuget.org/packages/Flurl/) without the HTTP features:
PM> Install-Package Flurl