Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: move base directory path normalization to frontend

Andras Bacsai981fc127b505
diff --git a/app/Livewire/Project/New/GithubPrivateRepository.php b/app/Livewire/Project/New/GithubPrivateRepository.php
index 27ecacb996..5dd508c291 100644
--- a/app/Livewire/Project/New/GithubPrivateRepository.php
+++ b/app/Livewire/Project/New/GithubPrivateRepository.php
@@ -75,16 +75,6 @@ class GithubPrivateRepository extends Component
$this->github_apps = GithubApp::private();
}
- public function updatedBaseDirectory()
- {
- if ($this->base_directory) {
- $this->base_directory = rtrim($this->base_directory, '/');
- if (! str($this->base_directory)->startsWith('/')) {
- $this->base_directory = '/'.$this->base_directory;
- }
- }
- }
-
public function updatedBuildPack()
{
if ($this->build_pack === 'nixpacks') {
diff --git a/app/Livewire/Project/New/PublicGitRepository.php b/app/Livewire/Project/New/PublicGitRepository.php
index 89814ee7fd..2fffff6b95 100644
--- a/app/Livewire/Project/New/PublicGitRepository.php
+++ b/app/Livewire/Project/New/PublicGitRepository.php
@@ -107,26 +107,6 @@ class PublicGitRepository extends Component
$this->query = request()->query();
}
- public function updatedBaseDirectory()
- {
- if ($this->base_directory) {
- $this->base_directory = rtrim($this->base_directory, '/');
- if (! str($this->base_directory)->startsWith('/')) {
- $this->base_directory = '/'.$this->base_directory;
- }
- }
- }
-
- public function updatedDockerComposeLocation()
- {
- if ($this->docker_compose_location) {
- $this->docker_compose_location = rtrim($this->docker_compose_location, '/');
- if (! str($this->docker_compose_location)->startsWith('/')) {
- $this->docker_compose_location = '/'.$this->docker_compose_location;
- }
- }
- }
-
public function updatedBuildPack()
{
if ($this->build_pack === 'nixpacks') {
diff --git a/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php b/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php
index 6d644ba2c8..596559817d 100644
--- a/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php
+++ b/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php
@@ -61,12 +61,33 @@
@endif
</div>
@if ($build_pack === 'dockercompose')
- <div x-data="{ baseDir: '{{ $base_directory }}', composeLocation: '{{ $docker_compose_location }}' }" class="gap-2 flex flex-col">
- <x-forms.input placeholder="/" wire:model.blur="base_directory" label="Base Directory"
- helper="Directory to use as root. Useful for monorepos." x-model="baseDir" />
- <x-forms.input placeholder="/docker-compose.yaml" wire:model.blur="docker_compose_location"
+ <div x-data="{
+ baseDir: '{{ $base_directory }}',
+ composeLocation: '{{ $docker_compose_location }}',
+ normalizePath(path) {
+ if (!path || path.trim() === '') return '/';
+ path = path.trim();
+ // Remove trailing slashes
+ path = path.replace(/\/+$/, '');
+ // Ensure leading slash
+ if (!path.startsWith('/')) {
+ path = '/' + path;
+ }
+ return path;
+ },
+ normalizeBaseDir() {
+ this.baseDir = this.normalizePath(this.baseDir);
+ },
+ normalizeComposeLocation() {
+ this.composeLocation = this.normalizePath(this.composeLocation);
+ }
+ }" class="gap-2 flex flex-col">
+ <x-forms.input placeholder="/" wire:model.defer="base_directory" label="Base Directory"
+ helper="Directory to use as root. Useful for monorepos." x-model="baseDir"
+ @blur="normalizeBaseDir()" />
+ <x-forms.input placeholder="/docker-compose.yaml" wire:model.defer="docker_compose_location"
label="Docker Compose Location" helper="It is calculated together with the Base Directory."
- x-model="composeLocation" />
+ x-model="composeLocation" @blur="normalizeComposeLocation()" />
<div class="pt-2">
<span>
Compose file location in your repository: </span><span class='dark:text-warning'
diff --git a/resources/views/livewire/project/new/github-private-repository.blade.php b/resources/views/livewire/project/new/github-private-repository.blade.php
index ddc5217c7f..e7f90788e8 100644
--- a/resources/views/livewire/project/new/github-private-repository.blade.php
+++ b/resources/views/livewire/project/new/github-private-repository.blade.php
@@ -95,15 +95,35 @@
@endif
</div>
@if ($build_pack === 'dockercompose')
- <div x-data="{ baseDir: '{{ $base_directory }}', composeLocation: '{{ $docker_compose_location }}' }" class="gap-2 flex flex-col">
- <x-forms.input placeholder="/" wire:model.blur="base_directory"
+ <div x-data="{
+ baseDir: '{{ $base_directory }}',
+ composeLocation: '{{ $docker_compose_location }}',
+ normalizePath(path) {
+ if (!path || path.trim() === '') return '/';
+ path = path.trim();
+ // Remove trailing slashes
+ path = path.replace(/\/+$/, '');
+ // Ensure leading slash
+ if (!path.startsWith('/')) {
+ path = '/' + path;
+ }
+ return path;
+ },
+ normalizeBaseDir() {
+ this.baseDir = this.normalizePath(this.baseDir);
+ },
+ normalizeComposeLocation() {
+ this.composeLocation = this.normalizePath(this.composeLocation);
+ }
+ }" class="gap-2 flex flex-col">
+ <x-forms.input placeholder="/" wire:model.defer="base_directory"
label="Base Directory"
helper="Directory to use as root. Useful for monorepos."
- x-model="baseDir" />
+ x-model="baseDir" @blur="normalizeBaseDir()" />
<x-forms.input placeholder="/docker-compose.yaml"
- wire:model.blur="docker_compose_location" label="Docker Compose Location"
+ wire:model.defer="docker_compose_location" label="Docker Compose Location"
helper="It is calculated together with the Base Directory."
- x-model="composeLocation" />
+ x-model="composeLocation" @blur="normalizeComposeLocation()" />
<div class="pt-2">
<span>
Compose file location in your repository: </span><span
diff --git a/resources/views/livewire/project/new/public-git-repository.blade.php b/resources/views/livewire/project/new/public-git-repository.blade.php
index a7804aad81..02489719a9 100644
--- a/resources/views/livewire/project/new/public-git-repository.blade.php
+++ b/resources/views/livewire/project/new/public-git-repository.blade.php
@@ -52,12 +52,33 @@
@endif
</div>
@if ($build_pack === 'dockercompose')
- <div x-data="{ baseDir: '{{ $base_directory }}', composeLocation: '{{ $docker_compose_location }}' }" class="gap-2 flex flex-col">
- <x-forms.input placeholder="/" wire:model.blur="base_directory" label="Base Directory"
- helper="Directory to use as root. Useful for monorepos." x-model="baseDir" />
- <x-forms.input placeholder="/docker-compose.yaml" wire:model.blur="docker_compose_location"
+ <div x-data="{
+ baseDir: '{{ $base_directory }}',
+ composeLocation: '{{ $docker_compose_location }}',
+ normalizePath(path) {
+ if (!path || path.trim() === '') return '/';
+ path = path.trim();
+ // Remove trailing slashes
+ path = path.replace(/\/+$/, '');
+ // Ensure leading slash
+ if (!path.startsWith('/')) {
+ path = '/' + path;
+ }
+ return path;
+ },
+ normalizeBaseDir() {
+ this.baseDir = this.normalizePath(this.baseDir);
+ },
+ normalizeComposeLocation() {
+ this.composeLocation = this.normalizePath(this.composeLocation);
+ }
+ }" class="gap-2 flex flex-col">
+ <x-forms.input placeholder="/" wire:model.defer="base_directory" label="Base Directory"
+ helper="Directory to use as root. Useful for monorepos." x-model="baseDir"
+ @blur="normalizeBaseDir()" />
+ <x-forms.input placeholder="/docker-compose.yaml" wire:model.defer="docker_compose_location"
label="Docker Compose Location" helper="It is calculated together with the Base Directory."
- x-model="composeLocation" />
+ x-model="composeLocation" @blur="normalizeComposeLocation()" />
<div class="pt-2">
<span>
Compose file location in your repository: </span><span class='dark:text-warning'