Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 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 Changed 5 years ago by stoecker

Description: modified (diff)

comment:2 Changed 5 years ago by Klumbumbus

Description: modified (diff)

comment:3 Changed 5 years ago by stoecker

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

comment:4 Changed 5 years ago by Don-vip

Milestone: 14.11

comment:5 Changed 5 years ago by Don-vip

Description: modified (diff)

comment:6 Changed 5 years ago by Don-vip

Resolution: fixed
Status: newclosed

In 7698/josm:

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

comment:7 Changed 5 years ago by Don-vip

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.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.