gca3020 / GABoardGameGeek

BoardGameGeek XMLAPI2 Swift Framework for interacting with games and collections on BGG
MIT License
8 stars 6 forks source link

Error on search with multiple words #12

Open tvisentin opened 5 years ago

tvisentin commented 5 years ago

Thanks for the API!

I have two errors when I do a search with several words: "7 wonders" or "Pandemic legacy", I have no results when I print searchResults... With just "wonders" it's working. And when I type just a number I have no results too :/

gca3020 commented 5 years ago

Thanks for the bug report. Glad the library is useful to you!

Unfortunately, I no longer have the time to maintain this library, but I just tried the queries you specified with the XML API Directly (https://www.boardgamegeek.com/xmlapi2/search?query=pandemic%20legacy), and (https://www.boardgamegeek.com/xmlapi2/search?query=7%20wonders), and both of them came back with results, so the behavior you're describing is not expected, and likely a bug.

If I had to guess (and this is going based on memory from a few years ago), I would say that the query params are probably not being formed correctly when they contain spaces.

I realize this is not a particularly helpful response, but if you want to try to fix the issue, I would start by adding a unit test in SearchSpec.swift, for query params like the ones I have listed above. I currently do not have a test for queries with spaces. As for an actual fix, in GABoardGameGeek.swift, my guess is that the string extension URLQueryParams on line 97 is not returning what I expect it to return. This code was initially developed in Swift 2, and I have not kept up with the current state of the art for Swift development, so it's possible this is a regression caused by the updates to Swift3/4.

If you do decide to investigate it, I will certainly review and merge any pull requests you submit to fix the issue.

Thanks!