Skip to content

Commit 3b2dee5

Browse files
committed
Fix: Prevent 'Undefined array key 1' when global Endpoint is requested
When multiple Endpoints are declared, and the frontend requests the global Endpoint (with only one path segment), accessing $segments[1] caused an 'Undefined array key' warning. This commit adds a count($segments) check to avoid invalid index access and preserve compatibility with global Endpoint logic.
1 parent 9078028 commit 3b2dee5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ServiceProvider.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ public function boot()
5656
// next look up the configured service endpoints
5757
$serviceUris = config('lodata.endpoints', []);
5858

59-
if (0 === sizeof($serviceUris)) {
60-
// when no locators are defined, fallback to global mode; this will
61-
// ensure compatibility with prior versions of this package
59+
if (0 === sizeof($serviceUris) || count($segments) === 1) {
60+
// when no locators are defined, or the global locator ist requested,
61+
// enter global mode; this will ensure compatibility with prior
62+
// versions of this package
6263
$service = new Endpoint('');
6364
}
6465
else if (array_key_exists($segments[1], $serviceUris)) {

0 commit comments

Comments
 (0)