- Timestamp:
- 2014-01-01T14:10:31+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r6524 r6588 5 5 6 6 import java.io.IOException; 7 import java.io.UnsupportedEncodingException;8 7 import java.net.URL; 9 import java.net.URLEncoder;10 8 import java.util.ArrayList; 11 9 import java.util.Collection; … … 137 135 } 138 136 139 protected final String encodePartialUrl(String url, String safePart) { 140 if (url != null && safePart != null) { 141 int pos = url.indexOf(safePart); 142 if (pos > -1) { 143 pos += safePart.length(); 144 try { 145 return url.substring(0, pos) + URLEncoder.encode(url.substring(pos), "UTF-8").replaceAll("\\+", "%20"); 146 } catch (UnsupportedEncodingException e) { 147 e.printStackTrace(); 148 } 149 } 150 } 137 /** 138 * This allows subclasses to perform operations on the URL before {@link #loadUrl} is performed. 139 */ 140 protected String modifyUrlBeforeLoad(String url) { 151 141 return url; 152 142 } … … 159 149 @Override 160 150 public Future<?> loadUrl(boolean new_layer, String url, ProgressMonitor progressMonitor) { 161 if (url.matches(PATTERN_OVERPASS_API_URL)) { 162 url = encodePartialUrl(url, "/interpreter?data="); // encode only the part after the = sign 163 164 } else if (url.matches(PATTERN_OVERPASS_API_XAPI_URL)) { 165 url = encodePartialUrl(url, "/xapi?"); // encode only the part after the ? sign 166 } 151 url = modifyUrlBeforeLoad(url); 167 152 downloadTask = new DownloadTask(new_layer, 168 153 new OsmServerLocationReader(url),
Note:
See TracChangeset
for help on using the changeset viewer.