From 4c74208e2b373b9124b4af1e21fd6c96fa239d9e Mon Sep 17 00:00:00 2001 From: flashwave Date: Sun, 4 Aug 2024 23:24:09 +0000 Subject: [PATCH] Fixed some templates not rendering. --- src/RoutingContext.php | 1 + src/StringableContentHandler.php | 18 ++++++++++++++++++ src/Torrents/AnnounceRouting.php | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/StringableContentHandler.php diff --git a/src/RoutingContext.php b/src/RoutingContext.php index a6c1c04..cd747e4 100644 --- a/src/RoutingContext.php +++ b/src/RoutingContext.php @@ -9,6 +9,7 @@ class RoutingContext { public function __construct(SeriaContext $context) { $this->router = new HttpRouter(errorHandler: new RoutingErrorHandler($context)); $this->router->use('/', fn($resp) => $resp->setPoweredBy('Seria')); + $this->router->registerContentHandler(new StringableContentHandler); // this should really be in Index lol but i can't be bothered rn! } public function getRouter(): IRouter { diff --git a/src/StringableContentHandler.php b/src/StringableContentHandler.php new file mode 100644 index 0000000..7d71e75 --- /dev/null +++ b/src/StringableContentHandler.php @@ -0,0 +1,18 @@ +setContent(new StringContent((string)$content)); + } +} diff --git a/src/Torrents/AnnounceRouting.php b/src/Torrents/AnnounceRouting.php index f4a8772..d1381ac 100644 --- a/src/Torrents/AnnounceRouting.php +++ b/src/Torrents/AnnounceRouting.php @@ -17,8 +17,8 @@ class AnnounceRouting extends RouteHandler { #[HttpGet('/announce')] #[HttpGet('/announce.php')] - #[HttpGet('/announce/:key')] - #[HttpGet('/announce.php/:key')] + #[HttpGet('/announce/([A-Za-z0-9]+)')] + #[HttpGet('/announce.php/([A-Za-z0-9]+)')] public function getAnnounce($response, $request, string $key = '') { if(strlen(inet_pton($_SERVER['REMOTE_ADDR'])) !== 4) return new AnnounceFailure('Tracker is only supported over IPv4, please reset your DNS cache.');