FIX: Correctly escape parameters in URL.#11
FIX: Correctly escape parameters in URL.#11jstastny wants to merge 1 commit intomeggsimum:masterfrom
Conversation
|
Strange, I tested without URLEncode an d without error with these 3 words : winkel. artenschutz. fängen public void testNonAsciiCharactersDE() {
What3Words w3w = new What3Words(API_KEY, "de");
String[] words = {"winkel", "artenschutz", "fängen"};
double[] coords;
try {
coords = w3w.wordsToPosition(words);
assertEquals(2, coords.length);
assertEquals(49.423903, coords[0]);
assertEquals(8.282732, coords[1]);
} catch (Exception e) {
assertTrue(false);
}
}I added a FR test with public void testNonAsciiCharatersFR() {
What3Words w3w = new What3Words(API_KEY, "fr");
String[] words = {"noël", "étain", "rizière"};
double[] coords;
try {
coords = w3w.wordsToPosition(words);
assertEquals(2, coords.length);
assertEquals(-21.951124, coords[0]);
assertEquals(166.685219, coords[1]);
} catch (Exception e) {
assertTrue(false);
}
}let's see what @chrismayer think about all of that. |
|
According to the comments in the thread: http://stackoverflow.com/questions/10786042/java-url-encoding-of-query-string-parameters, using the I will send a different merge request with the correct solution to this issue. |
|
Having done some more research on how to escape query parameters with plain Java (not using any external library as I otherwise do), it seems that the solution used in this merge request is probably one of the best. Surely, it is better that having no encoding of the query params at all. I am therefore reopening this. If somebody finds a better way to encode parameters with plain Java, they can contribute another merge request. |
Before this, the words containing non-ascii characters (for example "winkel", "artenschutz","fängen" -- see new test case) failed to resolve.