File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
main/java/com/arangodb/internal Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ v4.1.8 (2017-02-xx)
77* added ArangoCollection.drop(isSystem)
88* improved ArangoDBException with responseCode, errorNum, errorMessage
99* changed ArangoCollection.deleteDocuments() to work with keys and documents
10+ * fixed URL encoding bug (#97)
1011
1112v4.1.7 (2017-01-26)
1213---------------------------
Original file line number Diff line number Diff line change 2020
2121package com .arangodb .internal ;
2222
23+ import java .io .UnsupportedEncodingException ;
2324import java .lang .reflect .Type ;
25+ import java .net .URLEncoder ;
2426import java .util .Map ;
2527import java .util .regex .Pattern ;
2628
@@ -83,7 +85,17 @@ protected String createPath(final String... params) {
8385 if (i > 0 ) {
8486 sb .append ("/" );
8587 }
86- sb .append (params [i ]);
88+ try {
89+ final String param ;
90+ if (params [i ].contains ("/" ) || params [i ].contains (" " )) {
91+ param = params [i ];
92+ } else {
93+ param = URLEncoder .encode (params [i ], "UTF-8" );
94+ }
95+ sb .append (param );
96+ } catch (final UnsupportedEncodingException e ) {
97+ throw new ArangoDBException (e );
98+ }
8799 }
88100 return sb .toString ();
89101 }
Original file line number Diff line number Diff line change @@ -1660,4 +1660,12 @@ public void getRevision() {
16601660 assertThat (result .getRevision (), is (notNullValue ()));
16611661 }
16621662
1663+ @ Test
1664+ public void keyWithPunctuationCharacter () {
1665+ final String key = "myKey+" ;
1666+ db .collection (COLLECTION_NAME ).insertDocument (new BaseDocument (key ));
1667+ final BaseDocument doc = db .collection (COLLECTION_NAME ).getDocument (key , BaseDocument .class );
1668+ assertThat (doc , is (notNullValue ()));
1669+ assertThat (doc .getKey (), is (key ));
1670+ }
16631671}
You can’t perform that action at this time.
0 commit comments