Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
removes the uri prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Joan Fabrégat committed Oct 11, 2018
1 parent 5bb85d8 commit d2cfc80
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/AssetsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ class AssetsMiddleware implements MiddlewareInterface
*/
private $resolver;

/**
* Base assets URI path.
*
* @var string
*/
private $assetsUriPrefix;

/**
* Allows the assets to the cached in the web browser.
*
Expand All @@ -83,15 +76,13 @@ class AssetsMiddleware implements MiddlewareInterface
* AssetsMiddleware constructor.
*
* @param AssetResolverInterface $resolver
* @param string $assetsUriPrefix Base assets URI path
* @param bool $cacheAssets Allows the assets to the cached in the web browser
* @param bool $minifyAssets Minimizes the assets before sending them (@see AssetCompressedResponse)
*/
public function __construct(AssetResolverInterface $resolver, string $assetsUriPrefix = '/',
public function __construct(AssetResolverInterface $resolver,
bool $cacheAssets = true, bool $minifyAssets = false)
{
$this->resolver = $resolver;
$this->assetsUriPrefix = $assetsUriPrefix;
$this->cacheAssets = $cacheAssets;
$this->minifyAssets = $minifyAssets;
}
Expand Down Expand Up @@ -125,9 +116,7 @@ public function getAllowedMediaTypes():?array
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler):ResponseInterface
{
$reqUriPath = $request->getUri()->getPath();
if (preg_match('/^'.preg_quote($this->assetsUriPrefix, '/').'.+$/ui', $reqUriPath)
&& ($asset = $this->resolver->getAsset($reqUriPath)) !== null)
if (($asset = $this->resolver->getAsset($request->getUri()->getPath())) !== null)
{
try {
// checking the asset's media type
Expand Down Expand Up @@ -157,7 +146,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
throw new ResponseErrorException($asset, 0, $exception);
}
}

return $handler->handle($request);
}

Expand Down

0 comments on commit d2cfc80

Please sign in to comment.