Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Fix encoded URL #663

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function toResponse($request)
$page = [
'component' => $this->component,
'props' => $props,
'url' => Str::start(Str::after($request->fullUrl(), $request->getSchemeAndHttpHost()), '/'),
'url' => Str::start(Str::after(rawurldecode($request->fullUrl()), $request->getSchemeAndHttpHost()), '/'),
'version' => $this->version,
];

Expand Down
12 changes: 12 additions & 0 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,18 @@ public function test_the_page_url_doesnt_double_up(): void
$this->assertSame('/subpath/product/123', $page->url);
}

public function test_the_page_url_is_not_encoded(): void
{
$request = Request::create('/product/123', 'GET', ['value' => 'te/st']);
$request->headers->add(['X-Inertia' => 'true']);

$response = new Response('Product/Show', []);
$response = $response->toResponse($request);
$page = $response->getData();

$this->assertSame('/product/123?value=te/st', $page->url);
}

public function test_prop_as_basic_array(): void
{
$request = Request::create('/years', 'GET');
Expand Down
Loading