Skip to content

Commit

Permalink
Merge branch 'release/6.0.21'
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaskienast committed Oct 11, 2024
2 parents 1935815 + 9f13617 commit d35a109
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions legacy_hook/src/DocumentationLinker.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
*/
final readonly class DocumentationLinker
{
private const MAIN_IDENTIFIER = 'main';

private FilesystemAdapter $cache;
private int $cacheTime;

Expand Down Expand Up @@ -133,10 +135,16 @@ public function redirectToLink(): Response
$matches)
) {
[, $repository, $index] = $matches;
$version = str_replace('@', '', $matches[3] ?? '') ?: 'main';
$version = str_replace('@', '', $matches[3] ?? '') ?: self::MAIN_IDENTIFIER;
$entrypoint = $this->resolveEntryPoint($repository, $version);
$objectsContents = $this->getObjectsFile($entrypoint);

if ($objectsContents === '' && $version !== self::MAIN_IDENTIFIER) {
// soft-fail to resolve a maybe not-yet released version to main.
$entrypoint = $this->resolveEntryPoint($repository, self::MAIN_IDENTIFIER);
$objectsContents = $this->getObjectsFile($entrypoint);
}

if ($objectsContents === '') {
return new ResponseDescriber(404, [], 'Invalid shortcode, no objects.inv.json found.');
}
Expand Down Expand Up @@ -194,7 +202,7 @@ private function parseInventoryForIndex(string $index, array $json): string
// std:confval + pagelink.html#some-entry
// to:
// pagelink.html#confval-some-entry
$link = str_replace('#', '#-' . $docNodeTypeParts[1], $indexMetaData[2]);
$link = str_replace('#', '#' . $docNodeTypeParts[1] . '-', $indexMetaData[2]);
}
}
}
Expand Down

0 comments on commit d35a109

Please sign in to comment.