Skip to content

Commit

Permalink
fix: normalize request path methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Dec 6, 2024
1 parent f311f53 commit 8713b4d
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ public static function getScheme(): string
}

/**
* Get Script Name (physical path)
* Get Script Name
* @return string
*/
public static function getScriptName(): string
Expand All @@ -607,12 +607,26 @@ public static function getScriptName(): string
}

/**
* Get Path (physical path + virtual path)
* Get physical path
* @return string
*/
public static function getPhysicalPath(): string
{
return dirname($_SERVER['SCRIPT_NAME']);
}

/**
* Get Path
* @return string
*/
public static function getPath(): string
{
return static::getScriptName() . static::getPathInfo();
$physicalPath = static::getPhysicalPath();

return substr(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),
$physicalPath == '/' ? 0 : strlen($physicalPath)
);
}

/**
Expand All @@ -624,6 +638,15 @@ public static function getPathInfo(): ?string
return $_SERVER['REQUEST_URI'] ?? null;
}

/**
* Get query string
* @return string|null
*/
public static function getQueryString(): ?string
{
return $_SERVER['QUERY_STRING'] ?? null;
}

/**
* Get URL (scheme + host [ + port if non-standard ])
* @return string
Expand Down

0 comments on commit 8713b4d

Please sign in to comment.