Changeset 13489 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2018-03-03T20:33:09+01:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/TestError.java
r13453 r13489 191 191 * Sets a supplier to obtain a command to fix the error. 192 192 * 193 * @param fixingCommand the fix supplier 193 * @param fixingCommand the fix supplier. Can be null 194 194 * @return {@code this} 195 195 */ -
trunk/src/org/openstreetmap/josm/data/validation/tests/InternetTags.java
r12539 r13489 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 7 import java.util.function.Supplier; 8 9 import org.openstreetmap.josm.command.ChangePropertyCommand; 10 import org.openstreetmap.josm.command.Command; 7 11 import org.openstreetmap.josm.data.osm.Node; 8 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 97 101 String value = v != null ? v : p.get(k); 98 102 if (!validator.isValid(value)) { 103 Supplier<Command> fix = null; 99 104 String errMsg = validator.getErrorMessage(); 100 // Special treatment to allow URLs without protocol. See UrlValidator#isValid101 105 if (tr("URL contains an invalid protocol: {0}", (String) null).equals(errMsg)) { 106 // Special treatment to allow URLs without protocol. See UrlValidator#isValid 102 107 String proto = validator instanceof EmailValidator ? "mailto://" : "http://"; 103 108 return doValidateTag(p, k, proto+value, validator, code); 109 } else if (tr("URL contains an invalid authority: {0}", (String) null).equals(errMsg) 110 && value.contains("\\") && validator.isValid(value.replaceAll("\\\\", "/"))) { 111 // Special treatment to autofix URLs with backslashes. See UrlValidator#isValid 112 errMsg = tr("URL contains backslashes instead of slashes"); 113 fix = () -> new ChangePropertyCommand(p, k, value.replaceAll("\\\\", "/")); 104 114 } 105 115 error = TestError.builder(this, Severity.WARNING, code) 106 116 .message(validator.getValidatorName(), marktr("''{0}'': {1}"), k, errMsg) 107 117 .primitives(p) 118 .fix(fix) 108 119 .build(); 109 120 }
Note:
See TracChangeset
for help on using the changeset viewer.