Skip to content

Commit ec27abb

Browse files
authored
fix: preserving dots in query string (#132)
1 parent 7b8a982 commit ec27abb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Browser/HttpOptions.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Zenstruck\Browser;
1313

14+
use Symfony\Component\HttpFoundation\HeaderUtils;
15+
1416
/**
1517
* @author Kevin Bond <[email protected]>
1618
*
@@ -243,7 +245,7 @@ final public function addQueryToUrl(string $url): string
243245
}
244246

245247
if (isset($parts['query'])) {
246-
\parse_str($parts['query'], $query);
248+
$query = HeaderUtils::parseQuery($parts['query']);
247249
} else {
248250
$query = [];
249251
}

tests/HttpOptionsTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,12 @@ public function can_override_json_and_ajax_headers(): void
287287
$options->server()
288288
);
289289
}
290+
291+
/**
292+
* @test
293+
*/
294+
public function dots_in_query_string_are_preserved(): void
295+
{
296+
$this->assertSame('/?nested.param=value&deeper.nested.param=y', (new HttpOptions())->addQueryToUrl('/?nested.param=value&deeper.nested.param=y'));
297+
}
290298
}

0 commit comments

Comments
 (0)