Uri.Authority.toString renders leading double slash #784

jrudolph opened this Issue Jan 17, 2017 · 1 comment


None yet

2 participants


While the overall rendering of URIs is fine, Uri.Authority.toString will render leading double slashes (which will also fail the round-trip Uri.Authority.parse(authority.toString)):

scala> Uri("http://localhost/test").authority
res1: akka.http.scaladsl.model.Uri.Authority = //localhost

scala> Uri.Authority.parse(res1.toString)
akka.http.scaladsl.model.IllegalUriException: Illegal authority: Invalid input '/', expected authority or 'EOI' (line 1, column 1): //localhost
  at akka.http.scaladsl.model.IllegalUriException$.apply(ErrorInfo.scala:40)
  at akka.http.scaladsl.model.Uri$.fail(Uri.scala:750)
  at akka.http.impl.model.parser.UriParser.fail(UriParser.scala:77)
  at akka.http.impl.model.parser.UriParser.parseAuthority(UriParser.scala:72)
  at akka.http.scaladsl.model.Uri$Authority$.parse(Uri.scala:331)
  ... 42 elided

This doesn't seem to be covered by the spec.


   The generic URI syntax consists of a hierarchical sequence of
   components referred to as the scheme, authority, path, query, and

      URI         = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

      hier-part   = "//" authority path-abempty / [...]


   The following are two example URIs and their component parts:

         \_/   \______________/\_________/ \_________/ \__/
          |           |            |            |        |
       scheme     authority       path        query   fragment
          |   _____________________|__
         / \ /                        \

So, the double slashes belong to the hier-part and not to the authority.

In URI we could move the rendering of the double slashes from renderAuthority (which is used in Authority.toString) to renderUriWithoutFragment. Hopefully making this change won't lead to much breakage.

@ktoso ktoso closed this in 8a5833b Jan 19, 2017
@ktoso ktoso added this to the 10.0.2 milestone Jan 19, 2017
ktoso commented Jan 19, 2017

Be sure to note this issue in the release notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment