Версия:

Модуль uri

Модуль uri

Общие сведения

A «URI» is a «Uniform Resource Identifier». The IETF standard says a URI string looks like this:

[scheme:]scheme-specific-part[#fragment]

A common type, a hierarchical URI, looks like this:

[scheme:][//authority][path][?query][#fragment]

For example the string 'https://tarantool.org/x.html#y' has three components:

  • https is the scheme,
  • tarantool.org/x.html is the path,
  • y is the fragment.

Tarantool’s URI module provides routines which convert URI strings into their components, or turn components into URI strings.

Индекс

Below is a list of all uri functions.

Имя Использование
uri.parse() Get a table of URI components
uri.format() Construct a URI from components
uri.parse(URI-string)
Параметры:
  • URI-string – a Uniform Resource Identifier
Возврат:

URI-components-table. Possible components are fragment, host, login, password, path, query, scheme, service.

Rtype:

Таблица

Пример:

tarantool> uri = require('uri')
---
...

tarantool> uri.parse('http://x.html#y')
---
- host: x.html
  scheme: http
  fragment: y
...
uri.format(URI-components-table[, include-password])
Параметры:
  • URI-components-table – a series of name:value pairs, one for each component
  • include-password – boolean. If this is supplied and is true, then the password component is rendered in clear text, otherwise it is omitted.
Возврат:

URI-string. Thus uri.format() is the reverse of uri.parse().

Rtype:

string

Пример:

tarantool> uri.format({host = 'x.html', scheme = 'http', fragment = 'y'})
---
- http://x.html#y
...