Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Utils\UrlUtils Class Reference

Utilities for manipulating URLs. More...

Static Public Member Functions

static parseUrl (string $url)
 Parse a possibly-relative URL into components.
 
static assembleUrl (array $urlParts)
 This function will reassemble a URL parsed with self::parseURL().
 
static removeDotSegments (string $urlPath)
 Remove all dot-segments in the provided URL path.
 
static expandUrl (string $url, string $base)
 Expand a relative URL using a base URL.
 
static matchesDomainList (string $url, array $domains)
 Check whether a given URL has a domain that occurs in a given set of domains.
 

Detailed Description

Utilities for manipulating URLs.

See also
https://tools.ietf.org/html/rfc3986

Member Function Documentation

◆ assembleUrl()

static Wikimedia\Parsoid\Utils\UrlUtils::assembleUrl ( array $urlParts)
static

This function will reassemble a URL parsed with self::parseURL().

Note no percent-encoding or syntax validation is performed.

Parameters
array$urlPartsURL parts, as output from self::parseUrl
Returns
string URL assembled from its component parts

◆ expandUrl()

static Wikimedia\Parsoid\Utils\UrlUtils::expandUrl ( string $url,
string $base )
static

Expand a relative URL using a base URL.

See also
https://tools.ietf.org/html/rfc3986#section-5.2.2
Parameters
string$urlRelative URL to expand
string$baseBase URL to expand relative to
Returns
string Expanded URL

◆ matchesDomainList()

static Wikimedia\Parsoid\Utils\UrlUtils::matchesDomainList ( string $url,
array $domains )
static

Check whether a given URL has a domain that occurs in a given set of domains.

Parameters
string$url
array$domainsArray of domains (strings)
Returns
bool True if the host part of $url ends in one of the strings in $domains

◆ parseUrl()

static Wikimedia\Parsoid\Utils\UrlUtils::parseUrl ( string $url)
static

Parse a possibly-relative URL into components.

Note no percent-decoding is performed, and only minimal syntax validation.

Parameters
string$url
Returns
(string|null)[]
  • 'scheme': Scheme of the url, if any.
  • 'authority': Authority part of the url, if any. This is the part in between the "//" and the path. For http, this is the "user@host:port".
  • 'path': Path part of the URL. Never null, but may be the empty string.
  • 'query': Query part of the URL, if any.
  • 'fragment': Fragment part of the URL, if any.

◆ removeDotSegments()

static Wikimedia\Parsoid\Utils\UrlUtils::removeDotSegments ( string $urlPath)
static

Remove all dot-segments in the provided URL path.

For example, '/a/./b/../c/' becomes '/a/c/'.

See also
https://tools.ietf.org/html/rfc3986#section-5.2.4
Note
Copied from MediaWiki's wfRemoveDotSegments
Parameters
string$urlPathURL path, potentially containing dot-segments
Returns
string URL path with all dot-segments removed

The documentation for this class was generated from the following file: