diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ff7b0b..de4c8a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +1.3.1 - 2023.03.12 +* fix previously introduced bug +* add method to clean a string + 1.3 - 2023.03.10 * update to dotclear 2.25 * use namespace diff --git a/_define.php b/_define.php index fccbd7e..e69e4a1 100644 --- a/_define.php +++ b/_define.php @@ -18,7 +18,7 @@ $this->registerModule( 'Clean URLs', 'Removes diacritics and punctuation from URLs', 'Pierre Rudloff and contributors', - '1.3', + '1.3.1', [ 'requires' => [['core', '2.25']], 'permissions' => dcCore::app()->auth->makePermissions([ diff --git a/dcstore.xml b/dcstore.xml index 8a75557..95f413b 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,10 +2,10 @@ Clean URLs - 1.3 + 1.3.1 Pierre Rudloff and contributors Removes diacritics and punctuation from URLs - https://github.com/JcDenis/cleanURLs/releases/download/v1.3/plugin-cleanURLs.zip + https://github.com/JcDenis/cleanURLs/releases/download/v1.3.1/plugin-cleanURLs.zip 2.25 https://github.com/JcDenis/cleanURLs https://github.com/JcDenis/cleanURLs diff --git a/src/CleanURLs.php b/src/CleanURLs.php index 517eb65..1e12969 100644 --- a/src/CleanURLs.php +++ b/src/CleanURLs.php @@ -222,16 +222,27 @@ class CleanURLs } /** - * Clean URLs from diacritics and punctuation + * Clean string from diacritics and punctuation + * + * @param null|string $str The string + * + * @return null|string The cleaned string + * */ + public static function cleanStr(?string $str): ?string + { + return is_string($str) ? strtr(self::removeAccents($str), ',!.?;', '-----') : $str; + } + + /** + * Clean post URLs from diacritics and punctuation * * @param object $blog Current blog * @param object $cur Cursor * * @return void * */ - public static function clean($blog, $cur) + public static function cleanPost($blog, $cur) { - $cur->post_url = self::removeAccents($cur->post_url); - $cur->post_url = strtr($cur->post_url, ',!.?;', '-----'); + $cur->post_url = self::cleanStr($cur->post_url); } } diff --git a/src/Prepend.php b/src/Prepend.php index 3eb58a8..1d9a4fb 100644 --- a/src/Prepend.php +++ b/src/Prepend.php @@ -32,7 +32,7 @@ class Prepend extends dcNsProcess return false; } - dcCore::app()->addBehavior('coreBeforePostCreate', [CleanURLs::class, 'clean']); + dcCore::app()->addBehavior('coreBeforePostCreate', [CleanURLs::class, 'cleanPost']); return true; }