elm / url

Build and parse URLs. Useful for HTTP and "routing" in single-page apps (SPAs)
https://package.elm-lang.org/packages/elm/url/latest/
BSD 3-Clause "New" or "Revised" License
75 stars 43 forks source link

Currently not possible to create a websocket url #5

Closed ChristophP closed 6 years ago

ChristophP commented 6 years ago

Since the library uses a protocol type, defined like this:

{-| Is the URL served over a secure connection or not?
-}
type Protocol = Http | Https

it is possible to use the library for anything other than http and https. But what about if somebody needs a websocket url? The schemes ... | Ws | Wss would have to be added to support that (which I would argue is the most common scheme in the web after http). But maybe there are also other cases not covered by this, so having ... | Other String might be a good idea too. It would be a shame if people coulnd't use this nice library because their scheme is not supported.

Also toUrl has a check for http or https hardcoded which makes it impossible for other schemes to be a URL. My personal opinion is that this library should be not make any assumptions on the scheme which is used and just treat it as the part before the : and //.

evancz commented 6 years ago

This library is not released yet.

Also, this library is primarily for handling the browser address line where the protocol will always be a kind of HTTP as far as I know. I've never heard of a website being at a websocket, for example.

If someone needs different URLs they can make a different library for now. We can expand later.