9. URI manipulation library based on UriParser
The URIPARSER module exposes uriParser library https://uriparser.github.io to Daslang.
All functions and symbols are in “uriparser” module, use require to get access to it.
require uriparser
9.1. Handled structures
- UriTextRangeA
Range of text in the URI.
- UriIp4Struct
- Fields
data : uint8[4] - IPv4 address portion of the URI.
- UriIp6Struct
- Fields
data : uint8[16] - IPv6 address porition of the URI.
- UriHostDataA
Host data portion of the URI (IPv4 or IPv6, or some future data). IPv4 address data.
- Fields
ip4 : UriIp4Struct ? - IPv6 address data.
ip6 : UriIp6Struct ? - Future host address data.
ipFuture : UriTextRangeA
- UriPathSegmentStructA
Part of the path portion of the URI.
- Fields
text : UriTextRangeA - Text of the path segment.
next : UriPathSegmentStructA ? - Next path segment, or null if this is the last segment.
- UriUriA
URI base class, contains all URI data. Scheme of the URI.
- Fields
scheme : UriTextRangeA - User information.
userInfo : UriTextRangeA - Host text.
hostText : UriTextRangeA - Host data portion of the URI (IPv4 or IPv6, or some future data).
hostData : UriHostDataA - Port text.
portText : UriTextRangeA - Head of the path.
pathHead : UriPathSegmentStructA ? - Tail of the path.
pathTail : UriPathSegmentStructA ? - Query portion of the URI.
query : UriTextRangeA - Fragment portion of the URI.
fragment : UriTextRangeA - Whether the path is absolute.
absolutePath : int - Whether the URI is owned by the parser.
owner : int
- Uri
- Uri implicit.empty() : bool()
Returns true if the given URI is empty.
- Uri implicit.size() : int()
Returns the size of the given URI.
- Uri implicit.status() : int()
Returns the status of the given URI (URI_SUCCESS, URI_ERROR_SYNTAX, etc.).
- Properties
empty : bool
size : int
status : int
- Fields
uri : UriUriA - URI implementation.
9.2. Initialization and finalization
- Uri() : Uri()
Creates new URI.
- using(arg0: block<(Uri#):void>)
Creates scoped URI variable.
- Arguments
arg0 : block<( Uri #):void> implicit
- Uri(arg0: string implicit) : Uri()
Creates new URI.
- Arguments
arg0 : string implicit
- using(arg0: string implicit; arg1: block<(Uri#):void>)
Creates scoped URI variable.
- Arguments
arg0 : string implicit
arg1 : block<( Uri #):void> implicit
- finalize(uri: Uri implicit)
Finalizer for the URI.
- Arguments
uri : Uri implicit
- clone(dest: Uri implicit; src: Uri implicit)
Clones the URI.
9.3. Escape and unescape
- escape_uri(uriStr: string implicit; spaceToPlus: bool; normalizeBreaks: bool) : string()
Adds escape characters to the URI.
- Arguments
uriStr : string implicit
spaceToPlus : bool
normalizeBreaks : bool
- unescape_uri(uriStr: string implicit) : string()
Remove escape characters from the URI.
- Arguments
uriStr : string implicit
9.4. Uri manipulations
- strip_uri(uri: Uri implicit; query: bool; fragment: bool) : Uri()
Removes query and fragment from the URI.
- Arguments
uri : Uri implicit
query : bool
fragment : bool
- add_base_uri(base: Uri implicit; relative: Uri implicit) : Uri()
Adds base URI to the relative URI.
- remove_base_uri(base: Uri implicit; relative: Uri implicit) : Uri()
Removes base URI from the relative URI.
- normalize(uri: Uri implicit) : bool()
Normalizes URI, i.e. removes redundant / and . characters.
- Arguments
uri : Uri implicit
- string(uri: Uri implicit) : string()
Converts URI to string.
- Arguments
uri : Uri implicit
- string(range: UriTextRangeA implicit) : string()
Converts URI to string.
- Arguments
range : UriTextRangeA implicit
- uri_for_each_query_kv(uri: Uri implicit; block: block<(string#;string#):void>)
Iterates over the URI query parameters.
- Arguments
uri : Uri implicit
block : block<(string#;string#):void> implicit
- normalize_uri(uriStr: string implicit) : string()
Normalizes URI. i.e. removes redundant / and . characters.
- Arguments
uriStr : string implicit
9.5. File name conversions
- to_unix_file_name(uri: Uri implicit) : string()
Converts URI to Unix file name.
- Arguments
uri : Uri implicit
- to_windows_file_name(uri: Uri implicit) : string()
Converts URI to Windows file name.
- Arguments
uri : Uri implicit
- to_file_name(uri: Uri implicit) : string()
Converts URI to the current platform file name.
- Arguments
uri : Uri implicit
- uri_from_file_name(filename: string implicit) : Uri()
Converts current platform file name to URI.
- Arguments
filename : string implicit
- uri_from_windows_file_name(filename: string implicit) : Uri()
Converts Windows file name to URI.
- Arguments
filename : string implicit
- uri_from_unix_file_name(filename: string implicit) : Uri()
Converts Unix file name to URI.
- Arguments
filename : string implicit
- uri_to_unix_file_name(uriStr: string implicit) : string()
Converts URI to Unix file name.
- Arguments
uriStr : string implicit
- uri_to_windows_file_name(uriStr: string implicit) : string()
Converts URI to Windows file name.
- Arguments
uriStr : string implicit
- unix_file_name_to_uri(uriStr: string implicit) : string()
Converts Unix file name to URI.
- Arguments
uriStr : string implicit
- windows_file_name_to_uri(uriStr: string implicit) : string()
Converts Windows file name to URI.
- Arguments
uriStr : string implicit
- uri_to_file_name(uriStr: string implicit) : string()
Converts URI to the current platform file name.
- Arguments
uriStr : string implicit
- file_name_to_uri(uriStr: string implicit) : string()
Converts current file name to URI.
- Arguments
uriStr : string implicit