From 5e4f2727e16da6fd74762226397aaf69709ba723 Mon Sep 17 00:00:00 2001 From: Izaya Date: Fri, 22 Jun 2018 11:48:21 +1000 Subject: [PATCH] added protocol detection to fget, to deal with actual URLs --- FRequest/OpenOS/usr/bin/fget.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/FRequest/OpenOS/usr/bin/fget.lua b/FRequest/OpenOS/usr/bin/fget.lua index 12d5aa7..2e859af 100644 --- a/FRequest/OpenOS/usr/bin/fget.lua +++ b/FRequest/OpenOS/usr/bin/fget.lua @@ -1,16 +1,18 @@ local net = require "net" local event = require "event" -local function parseURL(url) - local hp, path = url:match("(.-)(/.+)") - hp, path = hp or url, path or "/" +local function parseurl(url) + local proto,addr = url:match("(.-)://(.+)") + addr = addr or url + local hp, path = addr:match("(.-)(/.*)") + hp, path = hp or addr, path or "/" local host, port = hp:match("(.+):(.+)") - host, port = host or hp, port or 70 - return host, port, path + host = host or hp + return proto, host, port, path end local tArgs = {...} -local host, port, path = parseURL(tArgs[1]) +local proto, host, port, path = parseURL(tArgs[1]) local socket = net.open(host,port) socket:write("t"..path.."\n")