Skip to content

Commit 88b4ceb

Browse files
[Repo Assist] Make Http.AppendQueryToUrl public (#1664)
* Make Http.AppendQueryToUrl public (closes #1325) Remove `internal` modifier from `Http.AppendQueryToUrl` so callers can use it directly to build query strings without duplicating the escaping logic. Five unit tests added. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: trigger CI checks --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1ff7e46 commit 88b4ceb

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 8.1.0-beta
44

5+
- Make `Http.AppendQueryToUrl` public (closes #1325)
56
- Add `PreferOptionals` parameter to `JsonProvider` and `XmlProvider` (defaults to `true` to match existing behavior; set to `false` to use empty string or `NaN` for missing values, like the CsvProvider default) (closes #649)
67

78
## 8.0.0 - Feb 25 2026

src/FSharp.Data.Http/Http.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,7 @@ type Http private () =
20042004
(WebUtility.UrlEncode query).Replace("+", "%20")
20052005

20062006
/// Appends the query parameters to the url, taking care of proper escaping
2007-
static member internal AppendQueryToUrl(url: string, query) =
2007+
static member AppendQueryToUrl(url: string, query) =
20082008
match query with
20092009
| [] -> url
20102010
| query ->

tests/FSharp.Data.Core.Tests/Http.fs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,30 @@ let startHttpLocalServer() =
6969
member this.WorkerTask = workerTask
7070
member this.BaseAddress = baseAddress }
7171

72+
[<Test>]
73+
let ``AppendQueryToUrl with no query returns url unchanged`` () =
74+
Http.AppendQueryToUrl("https://example.com/api", []) |> should equal "https://example.com/api"
75+
76+
[<Test>]
77+
let ``AppendQueryToUrl appends query parameters`` () =
78+
Http.AppendQueryToUrl("https://example.com/api", [ "key", "value" ])
79+
|> should equal "https://example.com/api?key=value"
80+
81+
[<Test>]
82+
let ``AppendQueryToUrl appends multiple query parameters`` () =
83+
Http.AppendQueryToUrl("https://example.com/api", [ "a", "1"; "b", "2" ])
84+
|> should equal "https://example.com/api?a=1&b=2"
85+
86+
[<Test>]
87+
let ``AppendQueryToUrl uses ampersand when url already contains query`` () =
88+
Http.AppendQueryToUrl("https://example.com/api?existing=x", [ "key", "value" ])
89+
|> should equal "https://example.com/api?existing=x&key=value"
90+
91+
[<Test>]
92+
let ``AppendQueryToUrl percent-encodes special characters in keys and values`` () =
93+
Http.AppendQueryToUrl("https://example.com/search", [ "q", "hello world" ])
94+
|> should equal "https://example.com/search?q=hello%20world"
95+
7296
[<Test>]
7397
let ``Don't throw exceptions on http error`` () =
7498
use localServer = startHttpLocalServer()

0 commit comments

Comments
 (0)