diff --git a/CHANGELOG.md b/CHANGELOG.md index abc0d441b..bdb869d5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Release 2.4.5 🍧️ ([belomaxorka](https://github.com/belomaxorka)) - Added `TorrentPier instance hash` generation [\#1726](https://github.com/torrentpier/torrentpier/pull/1726) ([belomaxorka](https://github.com/belomaxorka)) - Added `m4a` extension support in M3U playback [\#1724](https://github.com/torrentpier/torrentpier/pull/1724) ([belomaxorka](https://github.com/belomaxorka)) +- Created `VersionHelper.php` [\#1731](https://github.com/torrentpier/torrentpier/pull/1731) ([belomaxorka](https://github.com/belomaxorka)) - Drop Ocelot announcer support 🫡 [\#1727](https://github.com/torrentpier/torrentpier/pull/1727) ([belomaxorka](https://github.com/belomaxorka)) - Show torrent's announcers list in `filelist.php` page [\#1708](https://github.com/torrentpier/torrentpier/pull/1708) ([belomaxorka](https://github.com/belomaxorka)) - [PHP 8.4] Fixed some deprecations [\#1718](https://github.com/torrentpier/torrentpier/pull/1718) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/library/includes/datastore/build_check_updates.php b/library/includes/datastore/build_check_updates.php index 874506e14..12ef71140 100644 --- a/library/includes/datastore/build_check_updates.php +++ b/library/includes/datastore/build_check_updates.php @@ -22,8 +22,8 @@ $data = []; $updaterDownloader = new \TorrentPier\Updater(); $updaterDownloader = $updaterDownloader->getLastVersion($bb_cfg['tp_updater_settings']['allow_pre_releases']); -$getVersion = versionFormatter($updaterDownloader['tag_name']); -$currentVersion = versionFormatter($bb_cfg['tp_version']); +$getVersion = \TorrentPier\Helpers\VersionHelper::removerPrefix($updaterDownloader['tag_name']); +$currentVersion = \TorrentPier\Helpers\VersionHelper::removerPrefix($bb_cfg['tp_version']); // Has update! if (\z4kn4fein\SemVer\Version::greaterThan($getVersion, $currentVersion)) { diff --git a/library/includes/functions.php b/library/includes/functions.php index 31c5186f4..9a2f8860d 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -2157,20 +2157,6 @@ function readUpdaterFile(): array|bool return json_decode(file_get_contents(UPDATER_FILE), true); } -/** - * Version formatter - * - * @param string $version - * @return string - */ -function versionFormatter(string $version): string -{ - $version = trim($version); - $version = mb_strtolower($version, 'UTF-8'); - - return str_replace('v', '', $version); -} - /** * IP Geolocation API * diff --git a/src/Helpers/VersionHelper.php b/src/Helpers/VersionHelper.php new file mode 100644 index 000000000..665342407 --- /dev/null +++ b/src/Helpers/VersionHelper.php @@ -0,0 +1,48 @@ +