Url final class
Minn\Support\Url · public/minn/src/Minn/Support/Url.php · 231 lines
URL shaping the escaping and query helpers share: the character cleanup esc_url applies, bracket encoding outside the authority, and query argument merging. Behaviour pinned by contracts/fixtures/api/functions.json.
Public
| static | withTrailingSlash(string $value): string# | The value with one trailing slash, whatever slashes or backslashes it ended in (trailingslashit). | |||||||||
| static | withoutTrailingSlash(string $value): string# | The value with every trailing slash and backslash taken off (untrailingslashit). | |||||||||
| static | clean(string $url, string $scheme = 'http'): string# | Spaces encoded, stray characters dropped, ";//" healed, a bare host given http; '' when nothing survives. | |||||||||
| static | encodeBrackets(string $url, array $parsed): string# | Square brackets after the authority are percent-encoded; the authority itself is left alone. @param array<string, mixed> $parsed
| |||||||||
| static | withQuery(string $uri, array $new, Closure $encode, Closure $build): string# | The URI with query arguments merged in (false removes one), the fragment kept, a bare query string treated as such; a URI that is only a query (or nothing) keeps its leading question mark.
| |||||||||
| static | validateForHttp(string $url, string $homeHost, int $homePort, Closure $externalAllowed, ?Closure $safePorts = NULL): ?string# | The checks wp_http_validate_url makes on a URL whose protocol already passed: an http(s) scheme, a host without credentials or a colon, no private address unless it is this site or allowed, only the safe ports (80, 443 and 8080 unless the caller's list says otherwise; the site's own always). Returns the URL, or null when refused.
| |||||||||
| static | buildQuery(array $data, string $prefix = ''): string# | A query string in the reference's spelling (probe query-args): keys and values as given, nested keys as `a%5Bb%5D`, null left out, booleans as 0/1. | |||||||||
| static | parse(string $url, int $component = -1): array|string|int|false|null# | parse_url that also accepts scheme-relative and path-only URLs; a single component by its PHP_URL_* constant. | |||||||||
| static | withScheme(string $url, string $scheme): string# | The URL under a scheme, or scheme-and-host stripped for 'relative'; a protocol-relative URL is read as http first. | |||||||||
| static | safeRedirect(string $location, Closure $allowedHosts): ?string# | A redirect target the site may send a browser to: http(s) only and a host the caller allows (local paths always pass). Credentials before the host are kept, as the reference keeps them: the host decides.
|
Internals 1
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | isPrivate(array $p): bool# | Whether an IPv4 address is one a request must not reach: anything outside the global range (private, loopback, link-local, shared CGNAT space with the clouds' metadata hosts, benchmarking, documentation, reserved), the old 6to4 relays and multicast, as the reference refuses them.
|
Nothing matches.