Updated URL Replace addon #1483

Merged
MrPetovan merged 18 commits from toddy/friendica-addons:2024.03-rc into 2024.03-rc 2024-03-19 18:00:46 +01:00
Showing only changes of commit 0bcf2d7c89 - Show all commits

View file

@ -30,13 +30,13 @@ function url_replace_addon_admin_post()
// Convert twelvefeet_sites into an array before setting the new value
$twelvefeet_sites = explode(PHP_EOL, $_POST['twelvefeet_sites']);
// Normalize URLs by using lower case, removing a trailing slash and whitespace
$twelvefeet_sites = array_map(fn($value): string => rtrim(trim(strtolower($value)), '/'), $twelvefeet_sites);
$twelvefeet_sites = array_map(fn ($value): string => rtrim(trim(strtolower($value)), '/'), $twelvefeet_sites);
// Do not store empty lines or duplicates
$twelvefeet_sites = array_filter($twelvefeet_sites, fn($value): bool => !empty($value));
$twelvefeet_sites = array_filter($twelvefeet_sites, fn ($value): bool => !empty($value));
$twelvefeet_sites = array_unique($twelvefeet_sites);
// Ensure a protocol and default to HTTPS
$twelvefeet_sites = array_map(
fn($value): string => substr($value, 0, 4) !== 'http' ? 'https://' . $value : $value,
fn ($value): string => substr($value, 0, 4) !== 'http' ? 'https://' . $value : $value,
$twelvefeet_sites
);
asort($twelvefeet_sites);
@ -174,7 +174,6 @@ function url_replace_render(array &$b)
}
}
if ($replaced) {
$b['html'] .= '<hr><p><small>' . DI::l10n()->t('(URL replace addon enabled for X, YouTube, Instagram and some news sites.)') . '</small></p>';
}