-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow account names with dashed in them to be imported correctly #8370
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -424,7 +424,8 @@ function ImportTabClass:DownloadCharacterList() | |||||||||||||||||||||||
accountName = self.controls.accountName.buf:gsub("^[%s?]+", ""):gsub("[%s?]+$", ""):gsub("%s", "+") | ||||||||||||||||||||||||
end | ||||||||||||||||||||||||
local sessionID = #self.controls.sessionInput.buf == 32 and self.controls.sessionInput.buf or (main.gameAccounts[accountName] and main.gameAccounts[accountName].sessionID) | ||||||||||||||||||||||||
launch:DownloadPage(realm.hostName.."character-window/get-characters?accountName="..accountName:gsub("-", "%%23"):gsub("#", "%%23").."&realm="..realm.realmCode, function(response, errMsg) | ||||||||||||||||||||||||
accountName = ReplaceDiscrimintorSafely(accountName) | ||||||||||||||||||||||||
launch:DownloadPage(realm.hostName.."character-window/get-characters?accountName="..accountName:gsub("#", "%%23").."&realm="..realm.realmCode, function(response, errMsg) | ||||||||||||||||||||||||
if errMsg == "Response code: 401" then | ||||||||||||||||||||||||
self.charImportStatus = colorCodes.NEGATIVE.."Sign-in is required." | ||||||||||||||||||||||||
self.charImportMode = "GETSESSIONID" | ||||||||||||||||||||||||
|
@@ -468,9 +469,9 @@ function ImportTabClass:DownloadCharacterList() | |||||||||||||||||||||||
self.charImportMode = "GETSESSIONID" | ||||||||||||||||||||||||
return | ||||||||||||||||||||||||
end | ||||||||||||||||||||||||
realAccountName = realAccountName:gsub("-", "#") | ||||||||||||||||||||||||
self.controls.accountName:SetText(realAccountName) | ||||||||||||||||||||||||
realAccountName = ReplaceDiscrimintorSafely(realAccountName) | ||||||||||||||||||||||||
accountName = realAccountName | ||||||||||||||||||||||||
self.controls.accountName:SetText(realAccountName) | ||||||||||||||||||||||||
self.charImportStatus = "Character list successfully retrieved." | ||||||||||||||||||||||||
self.charImportMode = "SELECTCHAR" | ||||||||||||||||||||||||
self.lastRealm = realm.id | ||||||||||||||||||||||||
|
@@ -1138,6 +1139,20 @@ function HexToChar(x) | |||||||||||||||||||||||
return string.char(tonumber(x, 16)) | ||||||||||||||||||||||||
end | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
function ReplaceDiscrimintorSafely(accountName) | ||||||||||||||||||||||||
reversedAccountName = string.reverse(accountName) | ||||||||||||||||||||||||
discriminatorIndex = 0 | ||||||||||||||||||||||||
for i = 1, #reversedAccountName do | ||||||||||||||||||||||||
local c = reversedAccountName:sub(i,i) | ||||||||||||||||||||||||
if c == "#" or c == "-" then | ||||||||||||||||||||||||
discriminatorIndex = i | ||||||||||||||||||||||||
break | ||||||||||||||||||||||||
end | ||||||||||||||||||||||||
end | ||||||||||||||||||||||||
discriminatorIndex = discriminatorIndex * -1 | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I just realized this can all be done in a single
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't know that was possible in lua, cool stuff, but I see you removed it anyways.
|
||||||||||||||||||||||||
return ReplaceCharAtIndex(accountName, discriminatorIndex, "#") | ||||||||||||||||||||||||
end | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
function UrlDecode(url) | ||||||||||||||||||||||||
if url == nil then | ||||||||||||||||||||||||
return | ||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this behave fine when saving previously imported accounts in settings?