mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(previews): avoid doubled scheme in preview URL templates
Closes #12136 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f55efc859d
commit
d4502bc514
@@ -337,6 +337,10 @@ class ApplicationPreview extends BaseModel
|
||||
$previewFqdn = str_replace('{{random}}', $random, $template);
|
||||
$previewFqdn = str_replace('{{domain}}', $host, $previewFqdn);
|
||||
$previewFqdn = str_replace('{{pr_id}}', (string) $this->pull_request_id, $previewFqdn);
|
||||
if (preg_match('#^(https?)://(.*)$#i', $previewFqdn, $matches)) {
|
||||
$schema = strtolower($matches[1]);
|
||||
$previewFqdn = $matches[2];
|
||||
}
|
||||
$previewUrl = "{$schema}://{$previewFqdn}{$path}";
|
||||
$sourceCanonical = DomainPortOverrides::withoutPort($sourceDomain);
|
||||
$port = $url->getPort() ?? ($this->application->domain_port_overrides[$sourceCanonical] ?? null);
|
||||
|
||||
@@ -394,6 +394,18 @@ it('copies the parent domain port override onto a generated preview domain', fun
|
||||
->toBe([8080]);
|
||||
});
|
||||
|
||||
it('uses the preview url template scheme instead of the parent scheme', function (string $template, string $expected) {
|
||||
$this->application->update(['preview_url_template' => $template]);
|
||||
|
||||
$preview = createPreviewForPortTests($this->application, 2163);
|
||||
|
||||
expect($preview->generatedPreviewDomain('http://app.example.com/api')['url'])->toBe($expected);
|
||||
})->with([
|
||||
'explicit https' => ['https://{{pr_id}}.preview.example.com', 'https://2163.preview.example.com/api'],
|
||||
'explicit uppercase https' => ['HTTPS://{{pr_id}}.preview.example.com', 'https://2163.preview.example.com/api'],
|
||||
'scheme-less inherits parent' => ['{{pr_id}}.preview.example.com', 'http://2163.preview.example.com/api'],
|
||||
]);
|
||||
|
||||
it('keeps every generated preview domain port override in the legacy compose parser', function () {
|
||||
$this->application->update([
|
||||
'build_pack' => 'dockercompose',
|
||||
|
||||
Reference in New Issue
Block a user