akka/akka-http

empty Uri fragment ignored

Open

#3,859 opened on Jun 29, 2021

View on GitHub
 (7 comments) (0 reactions) (0 assignees)Scala (598 forks)batch import
1 - triagedhelp wantedt:coret:model

Repository metrics

Stars
 (1,311 stars)
PR merge metrics
 (Avg merge 1d 10h) (2 merged PRs in 30d)

Description

The Uri.withFragment function does not allow one to set an empty fragment, which is allowed by the IETF spec I believe, and by the Uri constructor, as shown:

import akka.http.scaladsl.model.Uri
import Uri.*

scala> val good = Uri("https",Authority(Host("example.com")),Path./("doc"),None,Some(""))       
val good: akka.http.scaladsl.model.Uri = https://example.com/doc#

scala> val noFrag = Uri("https",Authority(Host("example.com")),Path./("doc"),None,None)
val noFrag: akka.http.scaladsl.model.Uri = https://example.com/doc

scala> noFrag.withFragment("")
val res3: akka.http.scaladsl.model.Uri = https://example.com/doc

Contributor guide