Модуль uri | Tarantool
Документация на русском языке
поддерживается сообществом

Модуль uri

URI stands for Uniform Resource Identifier - a sequence of characters that identifies a logical or physical resource. The IETF standard says a URI string looks like this:

[схема:]специальная-часть-схемы[#фрагмент]

Общий тип, иерархический URI, выглядит так:

[схема:][//адрес][путь][?запрос][#фрагмент]

Например, строка 'https://tarantool.org/x.html#y' содержит три компонента:

  • https is the scheme.
  • tarantool.org/x.html is the path.
  • y – фрагмент.

Tarantool’s URI module provides functions that convert URI strings into their components, or turn components into URI strings.

Ниже приведен перечень всех функций модуля uri.

Имя Назначение
uri.parse() Получение таблицы URI-компонентов
uri.format() Создание URI из компонентов
uri.parse(URI-string)

Parse a URI string into components. Possible components are:

  • fragment
  • host
  • ipv4
  • ipv6
  • login
  • password
  • path
  • query
  • scheme
  • service
  • unix

uri.parse() is the reverse of uri.format().

Параметры:
  • URI-string – Унифицированный идентификатор ресурса
возвращает:

URI components table.

тип возвращаемого значения:
 

Таблица

Пример:

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

tarantool> uri.parse('scheme://login:password@host:service'..
'/path1/path2/path3?q1=v1&q2=v2&q3=v3:1|v3:2#fragment')
---
- login: login
  params:
    q1:
    - v1
    q2:
    - v2
    q3:
    - v3:1|v3:2
  service: service
  fragment: fragment
  password: password
  scheme: scheme
  query: q1=v1&q2=v2&q3=v3:1|v3:2
  host: host
  path: /path1/path2/path3
...
uri.format(URI-components-table[, include-password])

Form a URI string from its components. Possible components are:

  • fragment
  • host
  • ipv4
  • ipv6
  • login
  • password
  • path
  • query
  • scheme
  • service
  • unix

uri.format() is the reverse of uri.parse().

Параметры:
  • URI-components-table – a series of name=value pairs, one for each component
  • include-password – логическое значение. Если указать значение true, то компонент пароля отображается открытым текстом, в остальных случаях не отображается.
возвращает:

URI string

тип возвращаемого значения:
 

строка

Пример:

tarantool> uri.format({scheme='scheme', login='login', password='password', host='host',
service='service', path='/path1/path2/path3', query='q1=v1&q2=v2&q3=v3'})
---
- scheme://login@host:service/path1/path2/path3
...
Нашли ответ на свой вопрос?
Обратная связь