String encodePath ( String in ) { try { String encodedString = HierarchicalUriComponents . encodeUriComponent ( in , "UTF-8" , HierarchicalUriComponents . Type . PATH_SEGMENT ) ; if ( encodedString . startsWith ( _design_prefix_encoded ) || encodedString . startsWith ( _local_prefix_encoded ) ) { // we replaced the first slash in the design or local doc URL, which we shouldn't // so let's put it back return encodedString . replaceFirst ( "%2F" , "/" ) ; } else { return encodedString ; } } catch ( UnsupportedEncodingException uee ) { // This should never happen as every implementation of the java platform is required // to support UTF-8. throw new RuntimeException ( "Couldn't encode ID " + in , uee ) ; } }
Encode a path in a manner suitable for a GET request