Skip to content

Commit

Permalink
Merge pull request #147 from disneystreaming/infinite-redirect
Browse files Browse the repository at this point in the history
fix infinite redirect
  • Loading branch information
Baccata authored Mar 24, 2022
2 parents b1be6d7 + d842267 commit 3c2243d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private[smithy4s] abstract class Docs[F[_]](
}
}
def routes: HttpRoutes[F] = HttpRoutes.of[F] {
case GET -> DocPath() =>
case r @ GET -> DocPath() if r.uri.query.isEmpty =>
PermanentRedirect(
Location(Uri.unsafeFromString(s"/$path/index.html?url=/$jsonSpec"))
)
Expand Down
6 changes: 6 additions & 0 deletions modules/http4s-swagger/test/resources/swaggerui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ object DocsSpec extends SimpleIOSuite with TestCompat {
)
}
}
test(
s"GET /$path/index.html?url=/test-file.json does not redirect"
) {
val request =
Request[IO](
method = Method.GET,
uri = Uri.unsafeFromString(
s"/$path/index.html?url=/test-file.json"
)
)
app.run(request).map { response =>
expect(response.status == Status.Ok)
}
}
test(s"GET $path/test-file.json fetches requested file") {
val filePath = s"/$path/test-file.json"
val request =
Expand Down

0 comments on commit 3c2243d

Please sign in to comment.