Function
Coguri_guess_from_user_input
Declaration [src]
char*
cog_uri_guess_from_user_input (
const char* uri_like,
gboolean is_cli_arg,
GError** error
)
Description [src]
Tries to assemble a valid URI from input that resembles a URI.
First, if is_cli_arg
is set, the input string is converted to UTF-8.
Then, the following heuristics may applied:
- If the input is already a valid URI with a known scheme, return it as-is.
- If the input is a relative path, or resembles a local file path, try to
resolve it to a full path and return a
file://
URI. - If a URI does not have any path, set
/
as the path. - As a last resort, try to prepend the
http://
scheme.
The main use case for this function is turning some “simpler” version
of a URI, as typically entered by a user in a browser URL entry
(e.g. wpewebkit.org/release
) and turn it into an actual
URI (http://wpewebkit.org/release/
) which can be then passed to WebKit.WebView.load_uri.
Parameters
uri_like
-
Type:
const char*
String containing a URI-like value.
The data is owned by the caller of the function. The value is a NUL terminated UTF-8 string. is_cli_arg
-
Type:
gboolean
Whether the URI-like string is from a command line option.
error
-
Type:
GError **
The return location for a recoverable error.
The argument can be NULL
.If the return location is not NULL
, then you must initialize it to aNULL
GError*
.The argument will left initialized to NULL
by the function if there are no errors.In case of error, the argument will be set to a newly allocated GError
; the caller will take ownership of the data, and be responsible for freeing it.