
---@class socket_url_parts*
---@field url? string Original URL.
---@field scheme? string scheme。
---@field authority? string authority。
---@field userinfo? string userinfo。
---@field user? string username.
---@field password? string password.
---@field host? string host.
---@field port? string|integer port.
---@field path? string path.
---@field params? string parameter.
---@field query? string query。
---@field fragment? string fragment。
---@field is_absolute? boolean Whether the path is absolute.
---@field is_directory? boolean Whether the directory path.

---@class socket_url*
---@field _VERSION string URL Module version.
---@type socket_url*
local M = {}

M._VERSION = nil

--- Escape URL components.
---@param value string text.
---@return string escaped Escape the result.
function M.escape(value) end

--- Anti-escape URL components.
---@param value string text.
---@return string unescaped Unescaping the result.
function M.unescape(value) end

--- Parse URL.
---@param url string URL。
---@param default? socket_url_parts* default value.
---@return socket_url_parts* parts Parse the results.
function M.parse(url, default) end

--- Build URL.
---@param parsed socket_url_parts* parse table.
---@return string url URL。
function M.build(parsed) end

--- Parse path.
---@param path string path.
---@return table parts Path fragment.
function M.parse_path(path) end

--- Build path.
---@param parsed table Path fragment.
---@param unsafe? boolean Whether to preserve unescaped characters.
---@return string path path.
function M.build_path(parsed, unsafe) end

--- Computes the absolute URL based on the base URL.
---@param base_url string base URL。
---@param relative_url string Relative URL.
---@return string absolute_url Absolute URL.
function M.absolute(base_url, relative_url) end

return M
