Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use URI to retrieve decoded path segments in ArmeriaServerRequest #4163

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ private[armeria] final case class ArmeriaServerRequest(ctx: ServiceRequestContex
override def underlying: Any = ctx

override val pathSegments: List[String] = {
// ctx.path() always starts with '/'.
if (ctx.path() == "/") {
Nil
} else {
ctx.path().substring(1).split("/").toList
}
val segments = uri.pathSegments.segments.map(_.v).filter(_.nonEmpty).toList
if (segments == List("")) Nil else segments // representing the root path as an empty list
}

override val queryParameters: QueryParams = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,12 @@ class ServerBasicTests[F[_], OPTIONS, ROUTE](
(backend, baseUri) =>
basicRequest.get(uri"$baseUri/api").send(backend).map(_.code shouldBe StatusCode.Ok)
},
testServer(in_path_paths_out_header_body, "Encoded path should be decoded") { case (i, paths) =>
pureResult(Right((i, paths.last)))
}{
(backend, baseUri) =>
basicRequest.get(uri"$baseUri/api/15/and/MIN%2FMAX").send(backend).map(_.body shouldBe Right("MIN/MAX"))
},
testServer(in_single_path, "single path should match single/ path")((_: Unit) => pureResult(Either.right[Unit, Unit](()))) {
(backend, baseUri) =>
basicRequest.get(uri"$baseUri/api/").send(backend).map(_.code shouldBe StatusCode.Ok)
Expand Down
Loading