Skip to content

Commit ac904f4

Browse files
committed
[LiveComponent] Fix LiveUrl by not providing query to matcher
1 parent aca8276 commit ac904f4

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/LiveComponent/src/Util/UrlFactory.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,8 @@ public function createFromPreviousAndProps(
3636
return null;
3737
}
3838

39-
// Make sure to handle only path and query
40-
$previousUrl = $parsed['path'] ?? '';
41-
if (isset($parsed['query'])) {
42-
$previousUrl .= '?'.$parsed['query'];
43-
}
44-
4539
try {
46-
$newUrl = $this->createPath($previousUrl, $pathMappedProps);
40+
$newUrl = $this->createPath($parsed['path'] ?? '', $pathMappedProps);
4741
} catch (ResourceNotFoundException|MethodNotAllowedException|MissingMandatoryParametersException) {
4842
return null;
4943
}

src/LiveComponent/tests/Unit/Util/UrlFactoryTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public static function provideTestCreate(): \Generator
4141

4242
yield 'keep_url_with_query_parameters' => [
4343
'input' => ['previousUrl' => 'https://symfony.com/foo/bar?prop1=val1&prop2=val2'],
44-
'/foo/bar?prop1=val1&prop2=val2',
44+
'expectedUrl' => '/foo/bar?prop1=val1&prop2=val2',
4545
'routerStubData' => [
46-
'previousUrl' => '/foo/bar?prop1=val1&prop2=val2',
47-
'newUrl' => '/foo/bar?prop1=val1&prop2=val2',
46+
'previousUrl' => '/foo/bar',
47+
'newUrl' => '/foo/bar',
4848
],
4949
];
5050

@@ -62,6 +62,10 @@ public static function provideTestCreate(): \Generator
6262
'queryMappedProps' => ['prop1' => 'val1', 'prop2' => 'val2'],
6363
],
6464
'expectedUrl' => '/foo/bar?prop1=val1&prop3=oldValue&prop2=val2',
65+
'routerStubData' => [
66+
'previousUrl' => '/foo/bar',
67+
'newUrl' => '/foo/bar',
68+
],
6569
];
6670

6771
yield 'add_path_parameters' => [

0 commit comments

Comments
 (0)