CUTR-at-USF / pelias-client-library

A Java library for the Mapzen Pelias Geocoder (https://mapzen.com/documentation/search/search/)
Other
2 stars 3 forks source link

Add URLEncoder to mText parameter when building the API query string #20

Closed jmfield2 closed 7 years ago

jmfield2 commented 7 years ago

This fixes an issue where spaces (and other characters) would break the query.

An alternative (possibly overkill) approach is to use a URIBuilder instead of StringBuilder.

None of the tests failed with this patch, and my local testing yields local results for "burger+k" instead of results outside of the US like it does now.

I did not add any Javadocs RE: the @throws for URLEncoder, and there were 2 other warnings about that when I compiled:

3 warnings
[WARNING] Javadoc Warnings
[WARNING] /home/icmp/pelias-client-library/src/main/java/edu/usf/cutr/pelias/SearchRequest.java:207: warning: no description for @throws
[WARNING] * @throws IOException
[WARNING] ^
[WARNING] /home/icmp/pelias-client-library/src/main/java/edu/usf/cutr/pelias/SearchRequest.java:229: warning: no description for @param
[WARNING] * @param args
[WARNING] ^
[WARNING] /home/icmp/pelias-client-library/src/main/java/edu/usf/cutr/pelias/SearchRequest.java:147: warning: no @throws for java.io.UnsupportedEncodingException
[WARNING] public SearchRequest build() throws java.io.UnsupportedEncodingException {
jmfield2 commented 7 years ago

I think those changes are done - the test (added to the same method) passes with the patch, and says this without the patch:

Failed tests:   testRequestParameters(edu.usf.cutr.pelias.SearchTest): expected:

<...cus.json?text=burger[+]king&api_key=dummyAp...> 
but was:
<...cus.json?text=burger[ ]king&api_key=dummyAp...>
barbeau commented 7 years ago

Thanks @jmfield2!

barbeau commented 7 years ago

Ok, this is now in the v1.0.1 release, which I just published to JCenter and Maven Central. So you should be able to bump version in mobullity and pull down the official release.

barbeau commented 7 years ago

This is really published to Maven Central now - see http://search.maven.org/#artifactdetails%7Cedu.usf.cutr%7Cpelias-client-library%7C1.0.1%7Cjar.