Constructs a full URL by combining the base URL with an optional path.
Description
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
Parameters
$pathstringoptional- Optional path to append to the base URL.
Default:
''
Source
public static function url(string $path = ''): string
{
if ($path === '') {
return static::baseUrl();
}
return static::baseUrl() . '/' . ltrim($path, '/');
}
Changelog
| Version | Description |
|---|---|
| 0.2.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.