Skip to content

Commit 30caba3

Browse files
feat: add searchParams fun to native URL (#320)
1 parent cc50f18 commit 30caba3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/url/native/URL.re

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,11 @@ let setSearchAsString = (t, searchString) => {
218218
Uri.with_query(t, Uri.query_of_encoded(searchString));
219219
};
220220
let setSearch = Uri.with_query;
221-
let searchParams = _url => assert(false);
221+
222+
let searchParams = (url): SearchParams.t => {
223+
let query = Uri.query(url);
224+
query;
225+
};
222226
let username = url => {
223227
switch (Uri.user(url)) {
224228
/* User can be empty, if the Uri has a password is parsed as Some(""),

packages/url/test/test_native.re

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ let url_tests = (
175175
"https://:[email protected]/auth",
176176
);
177177
}),
178+
case("searchParams", () => {
179+
let url = URL.makeExn("https://sancho.dev:8080?foo=bar");
180+
let searchParams = URL.searchParams(url);
181+
assert_entries(
182+
URL.SearchParams.entries(searchParams),
183+
[|("foo", "bar")|],
184+
);
185+
}),
178186
],
179187
);
180188

0 commit comments

Comments
 (0)