Skip to content

Commit a1323a8

Browse files
committed
move the regex pattern to the private constant issue 24068
1 parent b32b91b commit a1323a8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/internal/Magento/Framework/View/Element/Html/Link/Current.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
*/
2424
class Current extends Template
2525
{
26+
/**
27+
* Search redundant /index and / in url
28+
*/
29+
private const REGEX_INDEX_URL_PATTERN = '/(\/index|(\/))+($|\/$)/';
30+
2631
/**
2732
* Default path
2833
*
@@ -88,8 +93,8 @@ private function getMca()
8893
public function isCurrent()
8994
{
9095
return $this->getCurrent() ||
91-
preg_replace('/(\/index|(\/))+($|\/$)/', '', $this->getUrl($this->getPath()))
92-
== preg_replace('/(\/index|(\/))+($|\/$)/', '', $this->getUrl($this->getMca()));
96+
preg_replace(self::REGEX_INDEX_URL_PATTERN, '', $this->getUrl($this->getPath()))
97+
== preg_replace(self::REGEX_INDEX_URL_PATTERN, '', $this->getUrl($this->getMca()));
9398
}
9499

95100
/**

0 commit comments

Comments
 (0)