diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-03-26 00:18:41 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-03-26 00:18:41 +0000 |
commit | e77f1792005088f55353c6c85fe9335e60772754 (patch) | |
tree | 097b71fc87bae4e1b3a8dd4e0a7869e6976fd9c1 /src | |
parent | 5b279bac9eea05d764e9cd14c89a699da8898126 (diff) | |
download | luasocket-e77f1792005088f55353c6c85fe9335e60772754.tar.gz luasocket-e77f1792005088f55353c6c85fe9335e60772754.tar.bz2 luasocket-e77f1792005088f55353c6c85fe9335e60772754.zip |
Adjusted some of the broken examples.
Diffstat (limited to 'src')
-rw-r--r-- | src/inet.c | 1 | ||||
-rw-r--r-- | src/url.lua | 12 |
2 files changed, 8 insertions, 5 deletions
@@ -44,6 +44,7 @@ int inet_open(lua_State *L) | |||
44 | luaL_openlib(L, NULL, func, 0); | 44 | luaL_openlib(L, NULL, func, 0); |
45 | lua_settable(L, -3); | 45 | lua_settable(L, -3); |
46 | lua_pop(L, 1); | 46 | lua_pop(L, 1); |
47 | return 0; | ||
47 | } | 48 | } |
48 | 49 | ||
49 | /*=========================================================================*\ | 50 | /*=========================================================================*\ |
diff --git a/src/url.lua b/src/url.lua index de0474b..2b9e4dc 100644 --- a/src/url.lua +++ b/src/url.lua | |||
@@ -127,7 +127,7 @@ function parse(url, default) | |||
127 | -- empty url is parsed to nil | 127 | -- empty url is parsed to nil |
128 | if not url or url == "" then return nil end | 128 | if not url or url == "" then return nil end |
129 | -- remove whitespace | 129 | -- remove whitespace |
130 | url = string.gsub(url, "%s", "") | 130 | -- url = string.gsub(url, "%s", "") |
131 | -- get fragment | 131 | -- get fragment |
132 | url = string.gsub(url, "#(.*)$", function(f) parsed.fragment = f end) | 132 | url = string.gsub(url, "#(.*)$", function(f) parsed.fragment = f end) |
133 | -- get scheme | 133 | -- get scheme |
@@ -139,6 +139,7 @@ function parse(url, default) | |||
139 | url = string.gsub(url, "%?(.*)", function(q) parsed.query = q end) | 139 | url = string.gsub(url, "%?(.*)", function(q) parsed.query = q end) |
140 | -- get params | 140 | -- get params |
141 | url = string.gsub(url, "%;(.*)", function(p) parsed.params = p end) | 141 | url = string.gsub(url, "%;(.*)", function(p) parsed.params = p end) |
142 | -- path is whatever was left | ||
142 | if url ~= "" then parsed.path = url end | 143 | if url ~= "" then parsed.path = url end |
143 | local authority = parsed.authority | 144 | local authority = parsed.authority |
144 | if not authority then return parsed end | 145 | if not authority then return parsed end |
@@ -164,7 +165,8 @@ end | |||
164 | -- a stringing with the corresponding URL | 165 | -- a stringing with the corresponding URL |
165 | ----------------------------------------------------------------------------- | 166 | ----------------------------------------------------------------------------- |
166 | function build(parsed) | 167 | function build(parsed) |
167 | local url = parsed.path or "" | 168 | local ppath = parse_path(parsed.path or "") |
169 | local url = build_path(ppath) | ||
168 | if parsed.params then url = url .. ";" .. parsed.params end | 170 | if parsed.params then url = url .. ";" .. parsed.params end |
169 | if parsed.query then url = url .. "?" .. parsed.query end | 171 | if parsed.query then url = url .. "?" .. parsed.query end |
170 | local authority = parsed.authority | 172 | local authority = parsed.authority |
@@ -183,7 +185,7 @@ function build(parsed) | |||
183 | if authority then url = "//" .. authority .. url end | 185 | if authority then url = "//" .. authority .. url end |
184 | if parsed.scheme then url = parsed.scheme .. ":" .. url end | 186 | if parsed.scheme then url = parsed.scheme .. ":" .. url end |
185 | if parsed.fragment then url = url .. "#" .. parsed.fragment end | 187 | if parsed.fragment then url = url .. "#" .. parsed.fragment end |
186 | url = string.gsub(url, "%s", "") | 188 | -- url = string.gsub(url, "%s", "") |
187 | return url | 189 | return url |
188 | end | 190 | end |
189 | 191 | ||
@@ -214,7 +216,7 @@ function absolute(base_url, relative_url) | |||
214 | end | 216 | end |
215 | end | 217 | end |
216 | else | 218 | else |
217 | relative.path = absolute_path(base.path,relative.path) | 219 | relative.path = absolute_path(base.path or "", relative.path) |
218 | end | 220 | end |
219 | end | 221 | end |
220 | return build(relative) | 222 | return build(relative) |
@@ -231,7 +233,7 @@ end | |||
231 | function parse_path(path) | 233 | function parse_path(path) |
232 | local parsed = {} | 234 | local parsed = {} |
233 | path = path or "" | 235 | path = path or "" |
234 | path = string.gsub(path, "%s", "") | 236 | --path = string.gsub(path, "%s", "") |
235 | string.gsub(path, "([^/]+)", function (s) table.insert(parsed, s) end) | 237 | string.gsub(path, "([^/]+)", function (s) table.insert(parsed, s) end) |
236 | for i = 1, table.getn(parsed) do | 238 | for i = 1, table.getn(parsed) do |
237 | parsed[i] = unescape(parsed[i]) | 239 | parsed[i] = unescape(parsed[i]) |