Skip to content

Commit 35714d1

Browse files
committed
fix(hydra): make the docs.jsonld Link header URI relative, to match Caddy and make client responsible of matching the original requeest's protocol
1 parent cff61ea commit 35714d1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Hydra/State/HydraLinkProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
4545
return $this->decorated->process($data, $operation, $uriVariables, $context);
4646
}
4747

48-
$apiDocUrl = $this->urlGenerator->generate('api_doc', ['_format' => 'jsonld'], UrlGeneratorInterface::ABS_URL);
48+
$apiDocUrl = $this->urlGenerator->generate('api_doc', ['_format' => 'jsonld'], UrlGeneratorInterface::ABS_PATH);
4949
$linkProvider = $request->attributes->get('_api_platform_links') ?? new GenericLinkProvider();
5050

5151
foreach ($operation->getLinks() ?? [] as $link) {

src/Hydra/Tests/State/HydraLinkProcessorTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ public function testProcess(): void
4242
$context = ['request' => $request];
4343
$decorated = $this->createMock(ProcessorInterface::class);
4444
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
45-
$urlGenerator->expects($this->once())->method('generate')->with('api_doc', ['_format' => 'jsonld'], UrlGeneratorInterface::ABS_URL)->willReturn('/docs');
45+
$urlGenerator
46+
->expects($this->once())
47+
->method('generate')
48+
->with('api_doc', ['_format' => 'jsonld'], UrlGeneratorInterface::ABS_PATH)
49+
->willReturn('/docs')
50+
;
4651
(new HydraLinkProcessor($decorated, $urlGenerator))->process($data, $operation, [], $context);
4752
}
4853
}

0 commit comments

Comments
 (0)