fix: links with path

This commit is contained in:
Andras Bacsai 2023-09-24 17:39:12 +02:00
parent e9149e534d
commit e74899611b
5 changed files with 10 additions and 9 deletions

View File

@ -97,7 +97,7 @@ public function __construct(int $application_deployment_queue_id)
if ($this->pull_request_id !== 0) { if ($this->pull_request_id !== 0) {
$this->preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pull_request_id); $this->preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pull_request_id);
if ($this->application->fqdn) { if ($this->application->fqdn) {
$preview_fqdn = getOnlyFqdn(data_get($this->preview, 'fqdn')); $preview_fqdn = getFqdnWithoutPort(data_get($this->preview, 'fqdn'));
$template = $this->application->preview_url_template; $template = $this->application->preview_url_template;
$url = Url::fromString($this->application->fqdn); $url = Url::fromString($this->application->fqdn);
$host = $url->getHost(); $host = $url->getHost();

View File

@ -377,7 +377,7 @@ public function parse(bool $isNew = false): Collection
} else { } else {
$number = 0; $number = 0;
} }
$fqdn = getOnlyFqdn(data_get($fqdns, $number, $fqdns->first())); $fqdn = getFqdnWithoutPort(data_get($fqdns, $number, $fqdns->first()));
$environments = collect(data_get($service, 'environment')); $environments = collect(data_get($service, 'environment'));
$environments = $environments->map(function ($envValue) use ($value, $fqdn) { $environments = $environments->map(function ($envValue) use ($value, $fqdn) {
$envValue = Str::of($envValue)->replace($value, $fqdn); $envValue = Str::of($envValue)->replace($value, $fqdn);
@ -393,7 +393,7 @@ public function parse(bool $isNew = false): Collection
} else { } else {
$number = 0; $number = 0;
} }
$fqdn = getOnlyFqdn(data_get($fqdns, $number, $fqdns->first())); $fqdn = getFqdnWithoutPort(data_get($fqdns, $number, $fqdns->first()));
$url = Url::fromString($fqdn)->getHost(); $url = Url::fromString($fqdn)->getHost();
$environments = collect(data_get($service, 'environment')); $environments = collect(data_get($service, 'environment'));
$environments = $environments->map(function ($envValue) use ($value, $url) { $environments = $environments->map(function ($envValue) use ($value, $url) {

View File

@ -19,7 +19,7 @@ public function __construct(public Service $service)
if ($application->fqdn) { if ($application->fqdn) {
$fqdns = collect(Str::of($application->fqdn)->explode(',')); $fqdns = collect(Str::of($application->fqdn)->explode(','));
$fqdns->map(function ($fqdn) { $fqdns->map(function ($fqdn) {
$this->links->push(getOnlyFqdn($fqdn)); $this->links->push(getFqdnWithoutPort($fqdn));
}); });
} }
if ($application->ports) { if ($application->ports) {

View File

@ -241,12 +241,13 @@ function base_ip(): string
} }
return "localhost"; return "localhost";
} }
function getOnlyFqdn(String $fqdn) function getFqdnWithoutPort(String $fqdn)
{ {
$url = Url::fromString($fqdn); $url = Url::fromString($fqdn);
$host = $url->getHost(); $host = $url->getHost();
$scheme = $url->getScheme(); $scheme = $url->getScheme();
return "$scheme://$host"; $path = $url->getPath();
return "$scheme://$host$path";
} }
/** /**
* If fqdn is set, return it, otherwise return public ip. * If fqdn is set, return it, otherwise return public ip.

View File

@ -19,7 +19,7 @@ class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hove
@foreach (Str::of(data_get($application, 'fqdn'))->explode(',') as $fqdn) @foreach (Str::of(data_get($application, 'fqdn'))->explode(',') as $fqdn)
<li> <li>
<a class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white" <a class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white"
target="_blank" href="{{ getOnlyFqdn($fqdn) }}"> target="_blank" href="{{ getFqdnWithoutPort($fqdn) }}">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24" <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round"> stroke-linejoin="round">
@ -28,7 +28,7 @@ class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hove
<path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464" /> <path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464" />
<path <path
d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463" /> d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463" />
</svg>{{ getOnlyFqdn($fqdn) }} </svg>{{ getFqdnWithoutPort($fqdn) }}
</a> </a>
</li> </li>
@endforeach @endforeach
@ -38,7 +38,7 @@ class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hove
@if (data_get($preview, 'fqdn')) @if (data_get($preview, 'fqdn'))
<li> <li>
<a class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white" <a class="text-xs text-white rounded-none hover:no-underline hover:bg-coollabs hover:text-white"
target="_blank" href="{{ getOnlyFqdn(data_get($preview, 'fqdn')) }}"> target="_blank" href="{{ getFqdnWithoutPort(data_get($preview, 'fqdn')) }}">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24" <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round"> stroke-linejoin="round">