Skip to content

Commit

Permalink
fix: redirectLocation can get location of Permanent Redirect
Browse files Browse the repository at this point in the history
Previously, if the result was a 308 Permanent Redirect, then `redirectLocation(result)` would return
None.
  • Loading branch information
tmccombs committed Nov 20, 2023
1 parent 18b6720 commit adf1c14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ trait ResultExtractors {
case ResponseHeader(SEE_OTHER, headers, _) => headers.get(LOCATION)
case ResponseHeader(TEMPORARY_REDIRECT, headers, _) => headers.get(LOCATION)
case ResponseHeader(MOVED_PERMANENTLY, headers, _) => headers.get(LOCATION)
case ResponseHeader(PERMANENT_REDIRECT, headers, _) => headers.get(LOCATION)
case ResponseHeader(_, _, _) => None
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ class HelpersSpec extends Specification {
}
}

"redirectLocation" should {
"extract location for 308 Permanent Redirect" in {
redirectLocation(Future.successful(PermanentRedirect("/test"))) must beSome("/test")
}
}

def restoringSysProp[T](propName: String)(block: => T): T = {
val original = sys.props.get(propName)
try {
Expand Down

0 comments on commit adf1c14

Please sign in to comment.