2016-04-30 18:47:48 +03:00
|
|
|
<?php
|
2019-10-05 18:26:10 +03:00
|
|
|
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-08-07 12:05:20 +03:00
|
|
|
use function Shlinkio\Shlink\Common\env;
|
|
|
|
|
2021-09-26 12:20:29 +03:00
|
|
|
use const Shlinkio\Shlink\DEFAULT_SHORT_CODES_LENGTH;
|
|
|
|
use const Shlinkio\Shlink\MIN_SHORT_CODES_LENGTH;
|
2021-08-07 12:05:20 +03:00
|
|
|
|
|
|
|
return (static function (): array {
|
2021-12-10 18:24:38 +03:00
|
|
|
$shortCodesLength = max(
|
|
|
|
(int) env('DEFAULT_SHORT_CODES_LENGTH', DEFAULT_SHORT_CODES_LENGTH),
|
|
|
|
MIN_SHORT_CODES_LENGTH,
|
|
|
|
);
|
2021-10-11 09:46:40 +03:00
|
|
|
$resolveSchema = static function (): string {
|
2021-12-10 18:24:38 +03:00
|
|
|
// Deprecated. For v3, IS_HTTPS_ENABLED should be true by default, instead of null
|
|
|
|
// return ((bool) env('IS_HTTPS_ENABLED', true)) ? 'https' : 'http';
|
|
|
|
$isHttpsEnabled = env('IS_HTTPS_ENABLED', env('USE_HTTPS'));
|
|
|
|
if ($isHttpsEnabled !== null) {
|
|
|
|
$boolIsHttpsEnabled = (bool) $isHttpsEnabled;
|
|
|
|
return $boolIsHttpsEnabled ? 'https' : 'http';
|
2021-10-11 09:46:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return env('SHORT_DOMAIN_SCHEMA', 'http');
|
|
|
|
};
|
2020-02-18 20:54:40 +03:00
|
|
|
|
2021-08-07 12:05:20 +03:00
|
|
|
return [
|
2016-04-30 18:47:48 +03:00
|
|
|
|
2021-08-07 12:05:20 +03:00
|
|
|
'url_shortener' => [
|
|
|
|
'domain' => [
|
2021-09-26 10:10:54 +03:00
|
|
|
// Deprecated SHORT_DOMAIN_* env vars
|
2021-10-11 09:46:40 +03:00
|
|
|
'schema' => $resolveSchema(),
|
2021-09-26 10:10:54 +03:00
|
|
|
'hostname' => env('DEFAULT_DOMAIN', env('SHORT_DOMAIN_HOST', '')),
|
2021-08-07 12:05:20 +03:00
|
|
|
],
|
|
|
|
'validate_url' => (bool) env('VALIDATE_URLS', false), // Deprecated
|
|
|
|
'default_short_codes_length' => $shortCodesLength,
|
|
|
|
'auto_resolve_titles' => (bool) env('AUTO_RESOLVE_TITLES', false),
|
|
|
|
'append_extra_path' => (bool) env('REDIRECT_APPEND_EXTRA_PATH', false),
|
2016-05-01 12:21:54 +03:00
|
|
|
],
|
2021-08-07 12:05:20 +03:00
|
|
|
|
|
|
|
];
|
|
|
|
})();
|