- v1.1.0 - Redesign
This commit is contained in:
@@ -135,3 +135,17 @@ function uniqueSlug(string $base): string {
|
||||
while (qval("SELECT id FROM businesses WHERE slug=?", [$slug.($i ? "-$i" : "")])) $i++;
|
||||
return $slug . ($i ? "-$i" : "");
|
||||
}
|
||||
|
||||
function businessVideoProvider(string $url): string {
|
||||
$host = strtolower((string)(parse_url(trim($url), PHP_URL_HOST) ?? ''));
|
||||
$host = preg_replace('/^www\./', '', $host);
|
||||
if ($host === 'youtu.be' || $host === 'youtube.com' || str_ends_with($host, '.youtube.com') || $host === 'youtube-nocookie.com' || str_ends_with($host, '.youtube-nocookie.com')) return 'YouTube';
|
||||
if ($host === 'vimeo.com' || str_ends_with($host, '.vimeo.com')) return 'Vimeo';
|
||||
return '';
|
||||
}
|
||||
function validBusinessVideoUrl(string $url): bool {
|
||||
$url = trim($url);
|
||||
if ($url === '') return true;
|
||||
$scheme = strtolower((string)(parse_url($url, PHP_URL_SCHEME) ?? ''));
|
||||
return in_array($scheme, ['http','https'], true) && businessVideoProvider($url) !== '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user