Skip to content

Commit

Permalink
Fix page resolution for endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbero90 committed Feb 7, 2024
1 parent 4ee6700 commit 77b43d3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Concerns/ResolvesPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Cerbero\LazyJsonPages\Concerns;

use Cerbero\JsonParser\Concerns\DetectsEndpoints;
use Cerbero\LazyJsonPages\Exceptions\InvalidPageInPathException;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
Expand All @@ -13,6 +14,8 @@
*/
trait ResolvesPages
{
use DetectsEndpoints;

/**
* Retrieve the page out of the given value.
*
Expand All @@ -23,8 +26,8 @@ protected function toPage(mixed $value, bool $onlyNumerics = true): string|int|n
return match (true) {
is_numeric($value) => (int) $value,
!is_string($value) || $value === '' => null,
!$parsedUri = parse_url($value) => $onlyNumerics ? null : $value,
default => $this->pageFromParsedUri($parsedUri, $onlyNumerics),
!$this->isEndpoint($value) => $onlyNumerics ? null : $value,
default => $this->pageFromParsedUri(parse_url($value), $onlyNumerics),
};
}

Expand Down

0 comments on commit 77b43d3

Please sign in to comment.