fix: exclude query params from REQUEST_PATH

This commit is contained in:
Nat 2024-09-01 14:56:21 -07:00
parent 9e7c18afba
commit ba8e95fa4f
2 changed files with 6 additions and 1 deletions

View File

@ -10,3 +10,5 @@ define('HOSTAS_UNIX_USER', 'www-data');
define('HOSTAS_ACCESS_LIST', array(
'example.org' => HOSTAS_ACCESS_LEVEL->trusted
));
define('HOSTAS_MAX_POSTS_PER_PAGE', 50);

View File

@ -1,9 +1,12 @@
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/config.php');
// $clean_uri is the request URI with any query strings removed
$clean_uri = strtok($_SERVER['REQUEST_URI'], '?');
// e.g. /api/v1/test/request/ -> ['', 'api', 'v1', 'test', 'request'].
// For convenience later, we take a slice that excludes ['', 'api', 'v1'].
define('REQUEST_PATH', array_slice(explode('/', $_SERVER['REQUEST_URI']), offset: 3));
define('REQUEST_PATH', array_slice(explode('/', $clean_uri), offset: 3));
switch (REQUEST_PATH[0]) {
case 'actor': // /api/v1/actor