Skip to content

Commit

Permalink
Fix redirect target url to be https://
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbiehl committed Feb 16, 2024
1 parent 7be973b commit 0471323
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/Scarf/Gateway/Rule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ matchPixel PixelRule {..} Request {requestWai}
| otherwise =
pure Nothing

-- | Match a catch-all rule. In its current form the only thing it does is redirect a request
-- | Match a catch-all rule. In its current form the only thing it does is redirect a request
-- to separate domain. Something that, in the past, has been done using file rules and catch-all
-- patterns like /{+path}. While effective URI templates are not great at dealing with encoding
-- specifics.
Expand All @@ -861,9 +861,7 @@ matchCatchAllV1 CatchAllRuleV1 {..} Request {requestWai}
let !absoluteUrl =
LBS.toStrict $
toLazyByteString $
-- Just using the protocol that the request came in with
-- allows for convenient testing.
(if Wai.isSecure requestWai then "https://" else "http://")
"https://"
<> Text.encodeUtf8Builder targetDomain
<> (
-- We would just like to use encodePath which is provided by http-types
Expand Down
4 changes: 2 additions & 2 deletions test/golden/catch-all-1.output.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
capture: |-
Just
FlatfileCapture
{ fileAbsoluteUrl = Just "http://downloads.test.sh/hello%20world"
{ fileAbsoluteUrl = Just "https://downloads.test.sh/hello%20world"
, fileVariables = fromList []
, filePackage = "8717953c-3452-4ef7-9a14-b64dc19163b4"
}
headers:
Location: http://downloads.test.sh/hello%20world
Location: https://downloads.test.sh/hello%20world
status: 302
4 changes: 2 additions & 2 deletions test/golden/catch-all-2.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ capture: |-
Just
FlatfileCapture
{ fileAbsoluteUrl =
Just "http://downloads.test.sh/search?q=hello%20world"
Just "https://downloads.test.sh/search?q=hello%20world"
, fileVariables = fromList []
, filePackage = "8717953c-3452-4ef7-9a14-b64dc19163b4"
}
headers:
Location: http://downloads.test.sh/search?q=hello%20world
Location: https://downloads.test.sh/search?q=hello%20world
query: ?q=hello%20world
status: 302

0 comments on commit 0471323

Please sign in to comment.