Skip to content

Commit

Permalink
3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Adinan Cenci committed Nov 13, 2021
1 parent 433d1fb commit c787ab5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGESLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 3.0.2 - 2021-11-13

## Fixed
- Routes were being attached to all HTTP methods instead of only the specidied ones.
- Files with extension longer than 3 characters were not being recognized as files.



## 3.0.1 - 2021-02-01
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "library",
"keywords": ["router"],
"license": "MIT",
"version": "3.0.1",
"version": "3.0.2",
"authors": [
{
"name": "Adinan Cenci",
Expand Down
12 changes: 9 additions & 3 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,17 +343,23 @@ protected function notFound($path)

protected function sortAddParams($params)
{
$methods = 'get|post|put|delete|options|patch';
$methods = null;
$patterns = null;
$callback = null;
$x = 0;

if ($params[0] == '*') {
if ($params[0] == '*') {
$methods = 'get|post|put|delete|options|patch';
$x++;
} else if (!is_array($params[0]) && !self::isRegexPattern($params[0])) {
$methods = $params[0];
$x++;
}

if (! $methods) {
$methods = 'get|post|put|delete|options|patch';
}

$patterns = $params[$x];
$callback = $params[$x + 1];

Expand All @@ -380,6 +386,6 @@ protected static function isRegexPattern($string)

protected static function isFilePath($string)
{
return preg_match('/\.[a-z]{3}$/', $string);
return preg_match('/\.[a-z]{3,4}$/', $string);
}
}

0 comments on commit c787ab5

Please sign in to comment.