diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-21 15:07:17 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-21 15:07:42 -0800 |
commit | 3b44b9827d5e9c6554c5600c45d832d4e6eb50f8 (patch) | |
tree | e2fc984be141e2e4fa18fceae6c73814d23c5646 /src/luasocket/url.lua | |
parent | f7ab5dd291f302c0fb97a2be0a11a06ed2bb6661 (diff) | |
download | teliva-3b44b9827d5e9c6554c5600c45d832d4e6eb50f8.tar.gz |
basic http requests starting to work
In the process we're starting to load almost all of luasocket by default. And everything is working as expected, no unpleasant surprises.
Diffstat (limited to 'src/luasocket/url.lua')
-rw-r--r-- | src/luasocket/url.lua | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/luasocket/url.lua b/src/luasocket/url.lua index 0a3a80a..a08d05f 100644 --- a/src/luasocket/url.lua +++ b/src/luasocket/url.lua @@ -7,11 +7,6 @@ ----------------------------------------------------------------------------- -- Declare module ----------------------------------------------------------------------------- -local string = require("string") -local base = _G -local table = require("table") -local socket = require("socket") - socket.url = {} local _M = socket.url @@ -43,7 +38,7 @@ end ----------------------------------------------------------------------------- local function make_set(t) local s = {} - for i,v in base.ipairs(t) do + for i,v in ipairs(t) do s[t[i]] = 1 end return s @@ -72,7 +67,7 @@ end ----------------------------------------------------------------------------- function _M.unescape(s) return (string.gsub(s, "%%(%x%x)", function(hex) - return string.char(base.tonumber(hex, 16)) + return string.char(tonumber(hex, 16)) end)) end @@ -143,7 +138,7 @@ end function _M.parse(url, default) -- initialize default parameters local parsed = {} - for i,v in base.pairs(default or parsed) do parsed[i] = v end + for i,v in pairs(default or parsed) do parsed[i] = v end -- empty url is parsed to nil if not url or url == "" then return nil, "invalid url" end -- remove whitespace @@ -211,7 +206,7 @@ function _M.build(parsed) if string.find(authority, ":") then -- IPv6? authority = "[" .. authority .. "]" end - if parsed.port then authority = authority .. ":" .. base.tostring(parsed.port) end + if parsed.port then authority = authority .. ":" .. tostring(parsed.port) end local userinfo = parsed.userinfo if parsed.user then userinfo = parsed.user @@ -238,7 +233,7 @@ end ----------------------------------------------------------------------------- function _M.absolute(base_url, relative_url) local base_parsed - if base.type(base_url) == "table" then + if type(base_url) == "table" then base_parsed = base_url base_url = _M.build(base_parsed) else |