mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-23 10:38:05 +11:00
added protocol detection to fget, to deal with actual URLs
This commit is contained in:
parent
3a769628e6
commit
5e4f2727e1
@ -1,16 +1,18 @@
|
|||||||
local net = require "net"
|
local net = require "net"
|
||||||
local event = require "event"
|
local event = require "event"
|
||||||
|
|
||||||
local function parseURL(url)
|
local function parseurl(url)
|
||||||
local hp, path = url:match("(.-)(/.+)")
|
local proto,addr = url:match("(.-)://(.+)")
|
||||||
hp, path = hp or url, path or "/"
|
addr = addr or url
|
||||||
|
local hp, path = addr:match("(.-)(/.*)")
|
||||||
|
hp, path = hp or addr, path or "/"
|
||||||
local host, port = hp:match("(.+):(.+)")
|
local host, port = hp:match("(.+):(.+)")
|
||||||
host, port = host or hp, port or 70
|
host = host or hp
|
||||||
return host, port, path
|
return proto, host, port, path
|
||||||
end
|
end
|
||||||
|
|
||||||
local tArgs = {...}
|
local tArgs = {...}
|
||||||
local host, port, path = parseURL(tArgs[1])
|
local proto, host, port, path = parseURL(tArgs[1])
|
||||||
|
|
||||||
local socket = net.open(host,port)
|
local socket = net.open(host,port)
|
||||||
socket:write("t"..path.."\n")
|
socket:write("t"..path.."\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user