Skip to content

Commit

Permalink
Merge pull request #2 from istiak-tridip/develop
Browse files Browse the repository at this point in the history
[v1.0.1] Merge the fixes
  • Loading branch information
istiak-tridip authored Feb 27, 2021
2 parents c8fb140 + 6f291de commit 987d546
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function send(string $path): void
$this->fetchFileContent($path);
}

$content = $this->cache()->fetch($path);
$content = $this->cache()->fetch($key);
$response = new SuccessResponse($content);
$response->send();
} catch (Throwable $exception) {
Expand Down Expand Up @@ -84,11 +84,13 @@ protected function checkIfPathIsAllowed(string $path): void
}

foreach ($paths as $pattern) {
if ($this->pathMatches($pattern, $path) === false) {
$response = new NotAllowedResponse($path);
$response->send();
if ($this->pathMatches($pattern, $path) === true) {
return;
}
}

$response = new NotAllowedResponse($path);
$response->send();
}

protected function pathMatches(string $pattern, string $path): bool
Expand All @@ -106,6 +108,6 @@ protected function getCacheKey(string $path): string
{
$host = parse_url($this->config["origin"]["base_uri"], PHP_URL_HOST);

return $host . "::" . $path;
return md5($host . "::" . $path);
}
}
17 changes: 17 additions & 0 deletions public/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

0 comments on commit 987d546

Please sign in to comment.