Opened 11 years ago

Last modified 11 years ago

#10696 closed enhancement

Provide a fix for website's with no scheme — at Version 2

Reported by: brianegge Owned by: team
Priority: normal Milestone: 14.11
Component: Core validator Version:
Keywords: Cc:

Description (last modified by Klumbumbus)

Frequently, the website tag is missing it's scheme. Id doesn't require this and it's not obvious that the scheme is required. The following patch will correct the scheme where it's obviously missing.

  • src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java

     
    156156    private static final String PORT_REGEX = "^:(\\d{1,5})$";
    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
    159162    /**
    160163     * Holds the set of current validation options.
    161164     */
     
    297300        String scheme = urlMatcher.group(PARSE_URL_SCHEME);
    298301        if (!isValidScheme(scheme)) {
    299302            setErrorMessage(tr("URL contains an invalid protocol: {0}", scheme));
     303            if (SIMPLE_WEBSITE_PATTERN.matcher(value).matches()) {
     304                setFix("http://" + value);
     305            }
    300306            return false;
    301307        }
    302308

Change History (2)

comment:1 by stoecker, 11 years ago

Description: modified (diff)

comment:2 by Klumbumbus, 11 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.