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

Fix redirect target url to be https:// #29

Merged
merged 1 commit into from
Feb 16, 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
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
Loading