Skip to content

Commit

Permalink
Issue CollaboraOnline#56: Replace strStartsWith() with str_starts_wit…
Browse files Browse the repository at this point in the history
…h().
  • Loading branch information
donquixote committed Nov 12, 2024
1 parent 5a0d2f4 commit 1a8c95c
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/Cool/CoolRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,6 @@ function getWopiSrcUrl($discovery_parsed, $mimetype) {
return NULL;
}

/**
* Checks if a string starts with another string.
*
* @param string $haystack
* Haystack.
* @param string $needle
* Needle.
*
* @return bool
* TRUE if $ss is a prefix of $s.
*
* @see str_starts_with()
*/
function strStartsWith($haystack, $needle) {
return strpos($haystack, $needle) === 0;
}

/**
* Service to fetch a WOPI client url.
*/
Expand All @@ -109,14 +92,14 @@ public function getWopiClientURL() {
}
$wopi_client_server = trim($wopi_client_server);

if (!strStartsWith($wopi_client_server, 'http')) {
if (!str_starts_with($wopi_client_server, 'http')) {
throw new CoolRequestException(
'Warning! You have to specify the scheme protocol too (http|https) for the server address.',
204,
);
}

if (!strStartsWith($wopi_client_server, $_HOST_SCHEME . '://')) {
if (!str_starts_with($wopi_client_server, $_HOST_SCHEME . '://')) {
throw new CoolRequestException(
'Collabora Online server address scheme does not match the current page url scheme.',
202,
Expand Down

0 comments on commit 1a8c95c

Please sign in to comment.