From afebd8831bcbf47fd4ca7d9feffedcf468012fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Treffler?= Date: Sun, 7 Sep 2025 18:26:34 +0200 Subject: [PATCH] account name fixes - fixes account name parsing - fixes account name encoding when passed as parameter --- looty/src/main/scala/looty/poeapi/PoeRpcs.scala | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/looty/src/main/scala/looty/poeapi/PoeRpcs.scala b/looty/src/main/scala/looty/poeapi/PoeRpcs.scala index a757ac5..be8f9bd 100644 --- a/looty/src/main/scala/looty/poeapi/PoeRpcs.scala +++ b/looty/src/main/scala/looty/poeapi/PoeRpcs.scala @@ -29,9 +29,13 @@ object PoeRpcs { import PoeTypes._ + def encodeURIComponent(uriComponent: String): String = { + return js.Dynamic.global.encodeURIComponent(uriComponent).asInstanceOf[String] + } + def getAccountName(): Future[String] = { AjaxHelp[String](s"$basePoeUrl/my-account", HttpRequestTypes.Get, None).flatMap { html => - val Regex = "href=\"/account/view-profile/([^\"]*)".r.unanchored + val Regex = "href=\"/account/view-profile/[^\"]+\">([^<]+)".r.unanchored html match { case Regex(accountName) => Future.successful(accountName) case _ => Future.failed(new Throwable("Unable to regex parse account name from page.")) @@ -46,8 +50,9 @@ object PoeRpcs { def getPassiveSkills(accountNameRealm: (String, Option[String]), character: String): Future[PassivesTree] = { //Also reqData=0 is sent sometimes //TODO + val accountName = encodeURIComponent(accountNameRealm._1) val anrs = { - s"accountName=${accountNameRealm._1}" + + s"accountName=${accountName}" + accountNameRealm._2.map(r => s"&realm=$r").getOrElse("") } enqueue[PassivesTree]( @@ -60,14 +65,14 @@ object PoeRpcs { def getCharacterInventory(accountNameRealm: (String, Option[String]), character: String): Future[Inventory] = { val p = newObject p.character = character - p.accountName = accountNameRealm._1 + p.accountName = encodeURIComponent(accountNameRealm._1) accountNameRealm._2.foreach(r => p.realm = r) enqueue[Inventory](url = s"$basePoeUrl/character-window/get-items", params = p) } def getStashTab(accountNameRealm: (String, Option[String]), league: String, tabIdx: Int): Future[StashTab] = { val p = newObject - p.accountName = accountNameRealm._1 + p.accountName = encodeURIComponent(accountNameRealm._1) p.league = league.toString p.tabIndex = tabIdx accountNameRealm._2.foreach(r => p.realm = r) @@ -76,7 +81,7 @@ object PoeRpcs { def getStashTabInfos(accountNameRealm: (String, Option[String]), league: String): Future[StashTabInfos] = { val p = newObject - p.accountName = accountNameRealm._1 + p.accountName = encodeURIComponent(accountNameRealm._1) accountNameRealm._2.foreach(r => p.realm = r) p.league = league.toString p.tabIndex = 0