Declaration [src]

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 an 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 an 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 an URI, as typically entered by an user in a browser URL entry (e.g. and turn it into an actual URI ( which can be then passed to WebKit.WebView.load_uri.


uri_like const char*

String containing an URI-like value.

 The data is owned by the caller of the function.
 The string is a NUL terminated UTF-8 string.
is_cli_arg gboolean

Whether the URI-like string is from a command line option.

error GError **
  The return location for a GError*, or NULL.

Return value

Returns: char*

A valid, full URI as a string. If NULL is returned, the error will also be set.

 The caller of the function takes ownership of the data, and is responsible for freeing it.
 The string is a NUL terminated UTF-8 string.