Skip to content

Commit 3ec5a6a

Browse files
fix: last word of the api prefix is removed in all cases
now it only removes the last word if it is a trailing slash `\` or slashes `\\`
1 parent 0cb0371 commit 3ec5a6a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Tasks/RenderApidocJsonTask.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@ public function __construct(string $docType)
1919
'name' => config('app.name'),
2020
'description' => config('app.name') . ' (' . ucfirst($docType) . ' API) Documentation',
2121
'title' => 'Welcome to ' . config('app.name'),
22-
'url' => config('apiato.api.url'),
23-
'sampleUrl' => config('vendor-documentation.enable-sending-sample-request') ? config('apiato.api.url') : null,
22+
'url' => $this->getFullUrl(),
23+
'sampleUrl' => config('vendor-documentation.enable-sending-sample-request') ? $this->getFullUrl() : null,
2424
];
2525
}
2626

27+
private function getFullUrl(): string
28+
{
29+
return config('apiato.api.url') . $this->prepareUrlPrefix();
30+
}
31+
32+
private function prepareUrlPrefix(): string
33+
{
34+
return rtrim(config('apiato.api.prefix'), '/');
35+
}
36+
2737
/**
2838
* Read the markdown header template and fill it with some real data from the .env file.
2939
*/
@@ -43,7 +53,7 @@ public function run(): string
4353
//Encode the array back into a JSON string.
4454
$jsonContent = json_encode($contentsDecoded);
4555

46-
// this is what the apidoc.json file will point to to load the header.md
56+
// this is what the apidoc.json file will point to, to load the header.md
4757
// write the actual file
4858
$path = app_path($this->outputPath);
4959
file_put_contents($path, $jsonContent);

0 commit comments

Comments
 (0)