Skip to content

Commit c30424e

Browse files
Merge pull request #692 from crynobone/v1-spec
[1.x] Ensure Inertia Response generate also compatible with Inertia.js 2
2 parents 9ab470d + bc897f8 commit c30424e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/Response.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ public function toResponse($request)
9595
'props' => $props,
9696
'url' => Str::start(Str::after($request->fullUrl(), $request->getSchemeAndHttpHost()), '/'),
9797
'version' => $this->version,
98+
'encryptHistory' => false,
99+
'clearHistory' => false,
98100
];
99101

100102
if ($request->header(Header::INERTIA)) {

tests/ControllerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public function test_controller_returns_an_inertia_response(): void
2828
],
2929
'url' => '/',
3030
'version' => '',
31+
'encryptHistory' => false,
32+
'clearHistory' => false,
3133
]);
3234
}
3335
}

tests/ResponseTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function test_server_response(): void
4646
$this->assertSame('Jonathan', $page['props']['user']['name']);
4747
$this->assertSame('/user/123', $page['url']);
4848
$this->assertSame('123', $page['version']);
49-
$this->assertSame('<div id="app" data-page="{&quot;component&quot;:&quot;User\/Edit&quot;,&quot;props&quot;:{&quot;user&quot;:{&quot;name&quot;:&quot;Jonathan&quot;}},&quot;url&quot;:&quot;\/user\/123&quot;,&quot;version&quot;:&quot;123&quot;}"></div>', $view->render());
49+
$this->assertSame('<div id="app" data-page="{&quot;component&quot;:&quot;User\/Edit&quot;,&quot;props&quot;:{&quot;user&quot;:{&quot;name&quot;:&quot;Jonathan&quot;}},&quot;url&quot;:&quot;\/user\/123&quot;,&quot;version&quot;:&quot;123&quot;,&quot;encryptHistory&quot;:false,&quot;clearHistory&quot;:false}"></div>', $view->render());
5050
}
5151

5252
public function test_xhr_response(): void
@@ -98,8 +98,7 @@ public function test_lazy_resource_response(): void
9898
$callable = static function () use ($users) {
9999
$page = new LengthAwarePaginator($users->take(2), $users->count(), 2);
100100

101-
return new class($page, JsonResource::class) extends ResourceCollection {
102-
};
101+
return new class($page, JsonResource::class) extends ResourceCollection {};
103102
};
104103

105104
$response = new Response('User/Index', ['users' => $callable], 'app', '123');

0 commit comments

Comments
 (0)