WordPress\AiClient\Providers\ApiBasedImplementation

AbstractApiProvider::urlpublic staticWP 0.2.0

Constructs a full URL by combining the base URL with an optional path.

This method ensures proper URL construction by:

  • Using the provider's base URL
  • Trimming leading slashes from the path to prevent double-slashes
  • Joining the base URL and path with a single forward slash

Method of the class: AbstractApiProvider{}

No Hooks.

Returns

String. The complete URL.

Usage

$result = AbstractApiProvider::url( $path ): string;
$path(string)
Optional path to append to the base URL.
Default: empty string

Changelog

Since 0.2.0 Introduced.

AbstractApiProvider::url() code WP 7.0

public static function url(string $path = ''): string
{
    if ($path === '') {
        return static::baseUrl();
    }
    return static::baseUrl() . '/' . ltrim($path, '/');
}