diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index f4efbdf..3f47bca 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -318,7 +318,7 @@ public static function fromRouteMatch(RouteMatchInterface $route_match) { */ public static function fromBaseRelativePath($path, $options = array()) { // Trim leading slashes to ensure a base-relative path is used. - $path = static::trimLeadingSlashes($path); + $path = ltrim($path, '/'); return static::fromUri(static::SCHEME_BASE . ':' . $path, $options); } @@ -352,24 +352,11 @@ public static function fromBaseRelativePath($path, $options = array()) { public static function fromHostRelativePath($path, $options = array()) { // Trim leading slashes, then add exactly one, to ensure a host-relative // path is used. - $path = static::trimLeadingSlashes($path); + $path = ltrim($path, '/'); return static::fromUri(static::SCHEME_BASE . ':/' . $path, $options); } /** - * Trims leading slashes from a path. - * - * @param string $path - * A potential base-relative or host-relative path. - * - * @return string - * The path, with leading slashes trimmed. - */ - protected static function trimLeadingSlashes($path) { - return preg_replace('/^(\/)+/', '', $path); - } - - /** * Creates a new Url object from a URI. * * This method is used to create URLs for internal and external URIs with a