mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 15:02:34 +00:00
Add site redirects (#552)
* feat(redirects): add redirects to sites * chore(style): fixed coding style issues * style: fix php-stan docblocks * style: pint cleanup * tests: fixed redirect test suite * feat: vhosts include additional configs * fix: use exact location matching * - add enums - use queues - use vhost rather than separate conf files - vhost formatter - cleanup * generate docs --------- Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
This commit is contained in:
@ -218,3 +218,36 @@ function home_path(string $user): string
|
||||
|
||||
return '/home/'.$user;
|
||||
}
|
||||
|
||||
function format_nginx_config(string $config): string
|
||||
{
|
||||
$lines = explode("\n", trim($config));
|
||||
$indent = 0;
|
||||
$formattedLines = [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$trimmed = trim($line);
|
||||
|
||||
// Preserve empty lines exactly as they are
|
||||
if ($trimmed === '') {
|
||||
$formattedLines[] = '';
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// If line is a closing brace, decrease indentation first
|
||||
if ($trimmed === '}') {
|
||||
$indent--;
|
||||
}
|
||||
|
||||
// Apply indentation
|
||||
$formattedLines[] = str_repeat(' ', max(0, $indent)).$trimmed;
|
||||
|
||||
// If line contains an opening brace, increase indentation
|
||||
if (str_ends_with($trimmed, '{')) {
|
||||
$indent++;
|
||||
}
|
||||
}
|
||||
|
||||
return implode("\n", $formattedLines)."\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user