Changeset 7902 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java
r7779 r7902 157 157 private static final Pattern PORT_PATTERN = Pattern.compile(PORT_REGEX); 158 158 159 private static final String SIMPLE_WEBSITE = "^www[.].*";160 private static final Pattern SIMPLE_WEBSITE_PATTERN = Pattern.compile(SIMPLE_WEBSITE);161 162 159 /** 163 160 * Holds the set of current validation options. … … 301 298 if (!isValidScheme(scheme)) { 302 299 setErrorMessage(tr("URL contains an invalid protocol: {0}", scheme)); 303 if (SIMPLE_WEBSITE_PATTERN.matcher(value).matches()) {304 setFix("http://" + value);305 }306 300 return false; 307 301 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/InternetTags.java
r7824 r7902 128 128 private TestError doValidateTag(OsmPrimitive p, String k, String v, AbstractValidator validator, int code) { 129 129 TestError error = null; 130 if (!validator.isValid(v != null ? v : p.get(k))) { 131 String msg = tr("''{0}'': {1}", k, validator.getErrorMessage()); 130 String value = v != null ? v : p.get(k); 131 if (!validator.isValid(value)) { 132 String errMsg = validator.getErrorMessage(); 133 // Special treatment to allow URLs without protocol. See UrlValidator#isValid 134 if (tr("URL contains an invalid protocol: {0}", (String)null).equals(errMsg)) { 135 String proto = validator instanceof EmailValidator ? "mailto://" : "http://"; 136 return doValidateTag(p, k, proto+value, validator, code); 137 } 138 String msg = tr("''{0}'': {1}", k, errMsg); 132 139 String fix = validator.getFix(); 133 140 if (fix != null) { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/InternetTagsTest.java
r7824 r7902 37 37 38 38 // Valid URLs 39 testUrl("url", "www.domain.com", true); // No protocol 39 40 testUrl("url", "http://josm.openstreetmap.de", true); // Simple HTTP 40 41 testUrl("url", "http://josm.openstreetmap.de/", true); // Simple HTTP + slash … … 48 49 49 50 // Invalid URLs 50 testUrl("url", "www.domain.com", false); // No protocol51 51 testUrl("url", "something://www.domain.com", false); // invalid protocol 52 52 testUrl("url", "http://www.domain.invalidtld", false); // invalid TLD
Note:
See TracChangeset
for help on using the changeset viewer.