diff --git a/scarf-gateway.cabal b/scarf-gateway.cabal index 2e27ef7..71ce31d 100644 --- a/scarf-gateway.cabal +++ b/scarf-gateway.cabal @@ -106,6 +106,7 @@ library , bytestring , case-insensitive , conduit + , containers , cryptohash-sha256 , exceptions , hashable diff --git a/src/Scarf/Gateway/Rule.hs b/src/Scarf/Gateway/Rule.hs index 3d51ef8..407e53b 100644 --- a/src/Scarf/Gateway/Rule.hs +++ b/src/Scarf/Gateway/Rule.hs @@ -36,6 +36,7 @@ import Data.ByteString.Base64.URL (encode) import Data.ByteString.Builder (Builder, char7, string7, toLazyByteString) import Data.ByteString.Char8 qualified as BS import Data.ByteString.Lazy qualified as LBS +import Data.Containers.ListUtils (nubOrdOn) import Data.HashMap.Strict (HashMap) import Data.HashMap.Strict qualified as HashMap import Data.HashSet (HashSet) @@ -665,7 +666,7 @@ rewriteQueryString redirectTarget request -- times -- after all, query strings may contain more than one occurrence of -- a variable. combinedQuery = - redirectTargetQuery <> requestQuery + nubOrdOn fst (redirectTargetQuery <> requestQuery) renderedQuery = Text.decodeUtf8 diff --git a/test/golden/file-package-with-variables-1.output.yaml b/test/golden/file-package-with-variables-1.output.yaml index 61db44e..9a7057b 100644 --- a/test/golden/file-package-with-variables-1.output.yaml +++ b/test/golden/file-package-with-variables-1.output.yaml @@ -3,13 +3,13 @@ capture: |- FlatfileCapture { fileAbsoluteUrl = Just - "https://datausa.io/api/data?drilldowns=Nation&measures=Population&drilldowns=Nation&measures=Population" + "https://datausa.io/api/data?drilldowns=Nation&measures=Population" , fileVariables = fromList [ ( "drilldowns" , "Nation" ) , ( "measures" , "Population" ) ] , filePackage = "a1b331fa-1539-49e5-bdc4-dc8a48e586d1" } headers: - Location: https://datausa.io/api/data?drilldowns=Nation&measures=Population&drilldowns=Nation&measures=Population + Location: https://datausa.io/api/data?drilldowns=Nation&measures=Population query: ?drilldowns=Nation&measures=Population status: 302 diff --git a/test/golden/file-package-with-variables-2.output.yaml b/test/golden/file-package-with-variables-2.output.yaml index d0dde97..18c77b1 100644 --- a/test/golden/file-package-with-variables-2.output.yaml +++ b/test/golden/file-package-with-variables-2.output.yaml @@ -3,13 +3,13 @@ capture: |- FlatfileCapture { fileAbsoluteUrl = Just - "https://datausa.io/api/data?drilldowns=Nation&measures=Population&measures=Population" + "https://datausa.io/api/data?drilldowns=Nation&measures=Population" , fileVariables = fromList [ ( "drilldowns" , "Nation" ) , ( "measures" , "Population" ) ] , filePackage = "a1b331fa-1539-49e5-bdc4-dc8a48e586d1" } headers: - Location: https://datausa.io/api/data?drilldowns=Nation&measures=Population&measures=Population + Location: https://datausa.io/api/data?drilldowns=Nation&measures=Population query: ?measures=Population status: 302 diff --git a/test/golden/file-package-without-varible-1.output.yaml b/test/golden/file-package-without-varible-1.output.yaml index 5b09cd2..4c4ffcf 100644 --- a/test/golden/file-package-without-varible-1.output.yaml +++ b/test/golden/file-package-without-varible-1.output.yaml @@ -3,11 +3,11 @@ capture: |- FlatfileCapture { fileAbsoluteUrl = Just - "https://datausa.io/api/data?drilldowns=Nation&measures=Population&drilldowns=Nation&measures=Population" + "https://datausa.io/api/data?drilldowns=Nation&measures=Population" , fileVariables = fromList [] , filePackage = "a1b331fa-1539-49e5-bdc4-dc8a48e586d1" } headers: - Location: https://datausa.io/api/data?drilldowns=Nation&measures=Population&drilldowns=Nation&measures=Population + Location: https://datausa.io/api/data?drilldowns=Nation&measures=Population query: ?drilldowns=Nation&measures=Population status: 302 diff --git a/test/golden/file-package-without-varible-2.output.yaml b/test/golden/file-package-without-varible-2.output.yaml index 5b09cd2..4c4ffcf 100644 --- a/test/golden/file-package-without-varible-2.output.yaml +++ b/test/golden/file-package-without-varible-2.output.yaml @@ -3,11 +3,11 @@ capture: |- FlatfileCapture { fileAbsoluteUrl = Just - "https://datausa.io/api/data?drilldowns=Nation&measures=Population&drilldowns=Nation&measures=Population" + "https://datausa.io/api/data?drilldowns=Nation&measures=Population" , fileVariables = fromList [] , filePackage = "a1b331fa-1539-49e5-bdc4-dc8a48e586d1" } headers: - Location: https://datausa.io/api/data?drilldowns=Nation&measures=Population&drilldowns=Nation&measures=Population + Location: https://datausa.io/api/data?drilldowns=Nation&measures=Population query: ?drilldowns=Nation&measures=Population status: 302