From 4dee76debb3857f69be701710f3aac2d7feb799c Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 9 Aug 2021 22:01:47 +0200 Subject: Merge regex pattern for search and feed controller --- index.php | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index a7d0ce6..8f34047 100644 --- a/index.php +++ b/index.php @@ -33,28 +33,16 @@ Router::add('', function() { }); #=============================================================================== -# ROUTE: Feed +# ROUTE: Feed and Search #=============================================================================== -Router::add('feed/', function() { - require 'core/include/feed/main.php'; +Router::add('(feed|search)/', function($slug) { + require "core/include/{$slug}/main.php"; }); #=============================================================================== -# ROUTE: Search +# REDIRECT: Feed and Search (trailing slash) #=============================================================================== -Router::add('search/', function() { - require 'core/include/search/main.php'; -}); - -#=============================================================================== -# REDIRECT: Feed (trailing slash) -#=============================================================================== -Router::addRedirect('feed', Application::getURL('feed/')); - -#=============================================================================== -# REDIRECT: Search (trailing slash) -#=============================================================================== -Router::addRedirect('search', Application::getURL('search/')); +Router::addRedirect('(feed|search)', Application::getURL('$1/')); #=============================================================================== # REDIRECT: Favicon -- cgit v1.2.3