diff options
author | Faraz Samapoor <fsamapoor@gmail.com> | 2023-05-15 15:17:19 +0330 |
---|---|---|
committer | Faraz Samapoor <fsamapoor@gmail.com> | 2023-05-15 15:17:19 +0330 |
commit | e7cc7653b885c49b1b3f0a78f91ea05a53e102d8 (patch) | |
tree | 42da61d5c6e988d7c9eff7e081327a73f661dc89 /lib/private/URLGenerator.php | |
parent | 8bdb50fd507bfe68161ab98eba903872083ea4f3 (diff) | |
download | nextcloud-server-e7cc7653b885c49b1b3f0a78f91ea05a53e102d8.tar.gz nextcloud-server-e7cc7653b885c49b1b3f0a78f91ea05a53e102d8.zip |
Refactors "strpos" calls in lib/private to improve code readability.
Signed-off-by: Faraz Samapoor <fsamapoor@gmail.com>
Diffstat (limited to 'lib/private/URLGenerator.php')
-rw-r--r-- | lib/private/URLGenerator.php | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index 2410b8a9147..3a52b99889c 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -272,13 +272,13 @@ class URLGenerator implements IURLGenerator { * @return string the absolute version of the url */ public function getAbsoluteURL(string $url): string { - $separator = strpos($url, '/') === 0 ? '' : '/'; + $separator = str_starts_with($url, '/') ? '' : '/'; if (\OC::$CLI && !\defined('PHPUNIT_RUN')) { return rtrim($this->config->getSystemValueString('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); } // The ownCloud web root can already be prepended. - if (\OC::$WEBROOT !== '' && strpos($url, \OC::$WEBROOT) === 0) { + if (\OC::$WEBROOT !== '' && str_starts_with($url, \OC::$WEBROOT)) { $url = substr($url, \strlen(\OC::$WEBROOT)); } @@ -302,7 +302,7 @@ class URLGenerator implements IURLGenerator { public function linkToDefaultPageUrl(): string { // Deny the redirect if the URL contains a @ // This prevents unvalidated redirects like ?redirect_url=:user@domain.com - if (isset($_REQUEST['redirect_url']) && strpos($_REQUEST['redirect_url'], '@') === false) { + if (isset($_REQUEST['redirect_url']) && !str_contains($_REQUEST['redirect_url'], '@')) { return $this->getAbsoluteURL(urldecode($_REQUEST['redirect_url'])); } |