Skip to content

Commit

Permalink
Removed unused validators. Patched rredirect URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredsgenkins committed Aug 25, 2020
1 parent 45b4a64 commit f0df332
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 294 deletions.
32 changes: 14 additions & 18 deletions src/Controller/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,32 @@ class Router extends BaseRouter
* @var ValidationManagerInterface
*/
protected $validationManager;

/**
* @var array
*/
protected $paths;

/**
* @var StoreManagerInterface
*/
private $storeManager;

/**
* @var UrlFinderInterface
*/
private $urlFinder;

/**
* @var ThemeProviderInterface
*/
private $themeProvider;

/**
* @var array
*/
private $ignoredURLs;

/**
* Router constructor.
* @param ActionList $actionList
Expand Down Expand Up @@ -113,7 +113,7 @@ public function __construct(
$pathConfig
);
}

/**
* @param RequestInterface $request
* @return ActionInterface|null
Expand Down Expand Up @@ -238,12 +238,8 @@ protected function redirectOn301(RequestInterface $request): void

if ($rewrite && in_array($rewrite->getRedirectType(), [301, 302])) {
$target = $rewrite->getTargetPath();

if ($target[0] !== '/') {
$target = '/' . $target;
}

$this->_performRedirect($target, $rewrite->getRedirectType());
$url = $this->_url->getDirectUrl($target);
$this->_performRedirect($url, $rewrite->getRedirectType());
}
}

Expand All @@ -269,17 +265,17 @@ protected function _performRedirect(string $url, int $type = 302): void
protected function isRequestIgnored(RequestInterface $request): bool
{
$requestPath = $request->getPathInfo();

foreach ($this->ignoredURLs as $pattern) {
// Use | as delimiter to allow / without escaping
if (preg_match('|' . $pattern . '|', $requestPath)) {
return true;
}
}

return false;
}

/**
* @param RequestInterface $request
* @param string $path
Expand All @@ -290,11 +286,11 @@ protected function _checkShouldBeSecure(RequestInterface $request, $path = '')
if ($request->getPostValue()) {
return;
}

if ($this->pathConfig->shouldBeSecure($path) && !$request->isSecure()) {
$alias = $request->getAlias(Url::REWRITE_REQUEST_PATH_ALIAS) ?: $request->getPathInfo();
$url = $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_WEB) . "$alias";

if ($this->_shouldRedirectToSecure()) {
$url = $this->_url->getRedirectUrl($url);
}
Expand Down
93 changes: 0 additions & 93 deletions src/Validator/Category.php

This file was deleted.

53 changes: 0 additions & 53 deletions src/Validator/Cms.php

This file was deleted.

126 changes: 0 additions & 126 deletions src/Validator/Product.php

This file was deleted.

6 changes: 2 additions & 4 deletions src/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
<preference for="ScandiPWA\Router\Controller\Router" type="ScandiPWA\Router\Controller\ConfigurableRouter"/>
<type name="Magento\Customer\Controller\Account\Confirm">
<plugin name="customize_email_validation_redirect"
type="ScandiPWA\Router\Controller\Customer\RedirectPlugin"></plugin>
type="ScandiPWA\Router\Controller\Customer\RedirectPlugin"
/>
</type>
<type name="ScandiPWA\Router\ValidationManager">
<arguments>
<argument name="validators" xsi:type="array">
<item name="category" xsi:type="string">ScandiPWA\Router\Validator\Category</item>
<item name="product" xsi:type="string">ScandiPWA\Router\Validator\Product</item>
<item name="page" xsi:type="string">ScandiPWA\Router\Validator\Cms</item>
<item name="cart" xsi:type="string">ScandiPWA\Router\Validator\AlwaysPass</item>
<item name="wishlist" xsi:type="string">ScandiPWA\Router\Validator\Wishlist</item>
<item name="checkout" xsi:type="string">ScandiPWA\Router\Validator\AlwaysPass</item>
Expand Down

0 comments on commit f0df332

Please sign in to comment.