Changeset 7902 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2014-12-28T18:59:56+01:00 (9 years ago)
Author:
Don-vip
Message:

see #10696 - allow URLs without protocol

Location:
trunk/src/org/openstreetmap/josm/data/validation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java

    r7779 r7902  
    157157    private static final Pattern PORT_PATTERN = Pattern.compile(PORT_REGEX);
    158158
    159     private static final String SIMPLE_WEBSITE = "^www[.].*";
    160     private static final Pattern SIMPLE_WEBSITE_PATTERN = Pattern.compile(SIMPLE_WEBSITE);
    161 
    162159    /**
    163160     * Holds the set of current validation options.
     
    301298        if (!isValidScheme(scheme)) {
    302299            setErrorMessage(tr("URL contains an invalid protocol: {0}", scheme));
    303             if (SIMPLE_WEBSITE_PATTERN.matcher(value).matches()) {
    304                 setFix("http://" + value);
    305             }
    306300            return false;
    307301        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/InternetTags.java

    r7824 r7902  
    128128    private TestError doValidateTag(OsmPrimitive p, String k, String v, AbstractValidator validator, int code) {
    129129        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);
    132139            String fix = validator.getFix();
    133140            if (fix != null) {
Note: See TracChangeset for help on using the changeset viewer.