socketry / async-http

MIT License
298 stars 45 forks source link

Endpoint.for should normalize URL #85

Closed adam12 closed 2 years ago

adam12 commented 2 years ago

When using Endpoint.parse, the generated URL is normalized before passing to the constructor, resulting in a path attribute of / by default.

When using Endpoint.for, the path is left as an empty String, which causes issues in some web servers. To make the behaviour consistent, Endpoint.for will normalize as well.

ioquatix commented 2 years ago

This looks good to me.

ioquatix commented 2 years ago

We could also have an optional path argument that defaults to "/". What do you think?

adam12 commented 2 years ago

I probably would have preferred to do it that way, but this seemed like the path of least resistance.

If you're open to adding an optional path argument with a default, I could submit a PR.

ioquatix commented 2 years ago

It’s totally up to you but it makes sense to me.