Skip to content

Commit 9838dcd

Browse files
authored
Use str_ends_with function for modules and plugins (joomla#44937)
1 parent cf530de commit 9838dcd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

plugins/system/sef/src/Extension/Sef.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public function enforceSuffix()
334334
$origUri = Uri::getInstance();
335335
$route = $origUri->getPath();
336336

337-
if (substr($route, -9) === 'index.php' || substr($route, -1) === '/') {
337+
if (str_ends_with($route, 'index.php') || str_ends_with($route, '/')) {
338338
// We don't want suffixes when the URL ends in index.php or with a /
339339
return;
340340
}
@@ -375,7 +375,7 @@ protected function removeIndexphp()
375375
{
376376
$origUri = Uri::getInstance();
377377

378-
if (substr($origUri->getPath(), -9) === 'index.php') {
378+
if (str_ends_with($origUri->getPath(), 'index.php')) {
379379
// Remove trailing index.php
380380
$origUri->setPath(substr($origUri->getPath(), 0, -9));
381381
$this->getApplication()->redirect($origUri->toString(), 301);

plugins/task/updatenotification/src/Extension/UpdateNotification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private function sendNotification(ExecuteTaskEvent $event): int
127127
// If we're here, we have updates. First, get a link to the Joomla! Update component.
128128
$baseURL = Uri::base();
129129
$baseURL = rtrim($baseURL, '/');
130-
$baseURL .= (substr($baseURL, -13) !== 'administrator') ? '/administrator/' : '/';
130+
$baseURL .= (!str_ends_with($baseURL, 'administrator')) ? '/administrator/' : '/';
131131
$baseURL .= 'index.php?option=com_joomlaupdate';
132132
$uri = new Uri($baseURL);
133133

0 commit comments

Comments
 (0)