Changeset 7019 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-04-28T16:41:29+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Utils.java
r7009 r7019 126 126 /** 127 127 * Returns the first element from {@code items} which is non-null, or null if all elements are null. 128 */ 128 * @param items the items to look for 129 * @return first non-null item if there is one 130 */ 131 @SafeVarargs 129 132 public static <T> T firstNonNull(T... items) { 130 133 for (T i : items) { … … 972 975 } 973 976 } 974 975 /** 976 * Fixes URL with illegal characters in the query (and fragment) part by 977 978 /** 979 * Fixes URL with illegal characters in the query (and fragment) part by 977 980 * percent encoding those characters. 978 * 981 * 979 982 * special characters like & and # are not encoded 980 * 983 * 981 984 * @param url the URL that should be fixed 982 985 * @return the repaired URL 983 986 */ 984 987 public static String fixURLQuery(String url) { 985 if (url.indexOf('?') == -1) 988 if (url.indexOf('?') == -1) 986 989 return url; 987 990 988 991 String query = url.substring(url.indexOf('?') + 1); 989 992 990 993 StringBuilder sb = new StringBuilder(url.substring(0, url.indexOf('?') + 1)); 991 994 992 995 for (int i=0; i<query.length(); i++) { 993 996 String c = query.substring(i, i+1); … … 1004 1007 return sb.toString(); 1005 1008 } 1006 1009 1007 1010 }
Note:
See TracChangeset
for help on using the changeset viewer.