Skip to content

Commit

Permalink
imp: improve URL parsing
Browse files Browse the repository at this point in the history
- Get full URL path
- Check and accept URL without port

Signed-off-by: Renato Foot <[email protected]>
  • Loading branch information
Renato Foot committed Nov 1, 2023
1 parent 195dd50 commit 930610e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions modules/client_entergame/entergame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,16 @@ function EnterGame.tryHttpLogin(clientVersion)
onCharacterList(nil, characters, account)
end

local host, path = G.host:match("([^/]+)/([^/]+)")
HTTP.post(host .. ':' .. G.port .. '/' .. path,
local host, path = G.host:match("([^/]+)/([^/].*)")
local url = G.host

if G.port ~= nil and path ~= nil then
url = host .. ':' .. G.port .. '/' .. path
elseif path ~= nil then
url = host .. '/' .. path
end

HTTP.post(url,
json.encode({
email = G.account,
password = G.password,
Expand Down Expand Up @@ -453,7 +461,7 @@ function EnterGame.doLogin()
g_settings.set('client-version', clientVersion)

if clientVersion >= 1281 and G.port ~= 7171 then
if G.port == nil or G.port == 0 then
if G.port == 0 then
G.port = 80
end

Expand Down

0 comments on commit 930610e

Please sign in to comment.