Skip to content

Commit 3baa438

Browse files
authored
Avoid frequent IllegalArgumentException (graphhopper#3123)
1 parent 218f4d9 commit 3baa438

File tree

1 file changed

+6
-1
lines changed
  • core/src/main/java/com/graphhopper/routing/ev

1 file changed

+6
-1
lines changed

core/src/main/java/com/graphhopper/routing/ev/State.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,13 @@ public enum State {
121121
* @param iso should be ISO 3166-2 but with hyphen like US-CA
122122
*/
123123
public static State find(String iso) {
124+
iso = iso.replace('-', '_');
125+
if (iso.indexOf('_') == -1) {
126+
return State.MISSING;
127+
}
128+
124129
try {
125-
return State.valueOf(iso.replace('-', '_'));
130+
return State.valueOf(iso);
126131
} catch (IllegalArgumentException ex) {
127132
return State.MISSING;
128133
}

0 commit comments

Comments
 (0)