URL: Uniform Resource Locator

https://en.m.wikipedia.org/wiki/URL

inline String toString(const Url &url)
URI_SCHEME_MAP(XX)
XX(name, str, port)

Common URI scheme strings.

class Url
#include <Url.h>

Class to manage URL instance.

Note

The various URL components are stored in un-escaped format for ease of editing. Unless otherwise indicated, methods act on un-escaped text. Methods used to obtain escaped versions are clearly marked. Any attached fragment (marked bv ‘#’) in the URL is discarded

Public Functions

inline Url(const String &urlString)

Construct a URL object from a regular escaped string.

Parameters:

urlString – Escaped URL

inline Url(const char *urlString)

Construct a URL object from a regular null-terminated escaped string.

Parameters:

urlString – Escaped URL

Url &operator=(String urlString)

Copy assignment operator.

Note

urlString is modified by so no point in passing const reference

Parameters:

urlString – Escaped URL

inline Url &operator=(const char *urlString)

Copy assignment operator, for C-style strings.

Parameters:

urlString – Escaped URL

String toString() const

Get escaped URL.

Return values:

String

inline int getPort() const

Obtain the actual port number to be used.

Note

If not specified, the default scheme port is returned

Return values:

int

String getHostWithPort() const

Get hostname+port part of URL string.

Note

Neither of these is subject to escaping

Return values:

String

inline String getRelativePath() const

Get path without leading separator.

Return values:

String

String getPathWithQuery() const

Get path with any query parameters attached.

Note

Both path and query values are escaped

Return values:

String

String getFileName() const

Obtain the filename part of the URL path.

Return values:

String

void debugPrintTo(Print &p) const

Printable output for debugging.

Parameters:

p

Public Members

String Scheme

without “:” and “//”

String Host

hostname or IP address

int Port = 0

Undefined by default.

String Path

with leading “/”

String Fragment

Without ‘#’.

Public Static Functions

static int getDefaultPort(const String &scheme)

Obtain the default port for a given scheme.

Return values:

int – 0 if scheme is not recognised or has no standard port defined