Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#10696 closed enhancement (fixed)

[PATCH] Provide a fix for website's with no scheme

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

Description (last modified by Don-vip)

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        }

Attachments (0)

Change History (7)

comment:1 by stoecker, 9 years ago

Description: modified (diff)

comment:2 by Klumbumbus, 9 years ago

Description: modified (diff)

comment:3 by stoecker, 9 years ago

Summary: Provide a fix for website's with no scheme[PATCH] Provide a fix for website's with no scheme

comment:4 by Don-vip, 9 years ago

Milestone: 14.11

comment:5 by Don-vip, 9 years ago

Description: modified (diff)

comment:6 by Don-vip, 9 years ago

Resolution: fixed
Status: newclosed

In 7698/josm:

fix #10696 - Provide a fix for website's with no scheme (patch by brianegge)

comment:7 by Don-vip, 9 years ago

In 7902/josm:

see #10696 - allow URLs without protocol

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.