Skip to content

Commit

Permalink
precentEncode paths that are passed as captures (#72)
Browse files Browse the repository at this point in the history
* precentEncode paths that are passed as captures

* fixed tests

* Install nix

---------

Co-authored-by: iko <mail@iko.soy>
  • Loading branch information
domenkozar and ilyakooo0 authored Apr 10, 2023
1 parent 2770172 commit 440a5e0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install Nix
uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Cache
uses: actions/cache@v3
env:
Expand Down
4 changes: 3 additions & 1 deletion src/Servant/Elm/Internal/Generate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ The default required imports are:
> import Set
> import Http
> import String
> import Url
> import Url.Builder
-}
defElmImports :: Text
Expand All @@ -132,6 +133,7 @@ defElmImports =
, "import Set"
, "import Http"
, "import String"
, "import Url"
, "import Url.Builder"
]

Expand Down Expand Up @@ -563,7 +565,7 @@ mkUrl opts segments =
toStringSrc =
toString opts (maybeOf (arg ^. F.argType))
in
pipeRight [elmCaptureArg s, toStringSrc]
"Url.percentEncode " <> pipeRight [elmCaptureArg s, toStringSrc]


mkQueryParams
Expand Down
4 changes: 4 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ packages:
- '.'
flags: {}
extra-package-dbs: []
nix:
enable: true
packages:
- zlib
3 changes: 2 additions & 1 deletion test/elm-sources/getBooksByIdSource.elm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ getBooksById capture_id toMsg =
, url =
Url.Builder.crossOrigin ""
[ "books"
, (capture_id |> String.fromInt)
, Url.percentEncode (capture_id
|> String.fromInt)
]
params
, body =
Expand Down
2 changes: 1 addition & 1 deletion test/elm-sources/getBooksByTitleSource.elm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ getBooksByTitle capture_title toMsg =
, url =
Url.Builder.crossOrigin ""
[ "books"
, (capture_title)
, Url.percentEncode (capture_title)
]
params
, body =
Expand Down

0 comments on commit 440a5e0

Please # to comment.