Opened 11 years ago

Last modified 11 years ago

#10696 closed enhancement

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

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

Description (last modified by stoecker)

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.

Index: src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java
===================================================================
--- src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java	(revision 7695)
+++ src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java	(working copy)
@@ -156,6 +156,9 @@
     private static final String PORT_REGEX = "^:(\\d{1,5})$";
     private static final Pattern PORT_PATTERN = Pattern.compile(PORT_REGEX);
 
+    private static final String SIMPLE_WEBSITE = "^www[.].*";
+    private static final Pattern SIMPLE_WEBSITE_PATTERN = Pattern.compile(SIMPLE_WEBSITE);
+
     /**
      * Holds the set of current validation options.
      */
@@ -297,6 +300,9 @@
         String scheme = urlMatcher.group(PARSE_URL_SCHEME);
         if (!isValidScheme(scheme)) {
             setErrorMessage(tr("URL contains an invalid protocol: {0}", scheme));
+            if (SIMPLE_WEBSITE_PATTERN.matcher(value).matches()) {
+                setFix("http://" + value);
+            }
             return false;
         }
 
Index: src/org/openstreetmap/josm/data/validation/tests/SimilarNamedWays.java

Change History (1)

comment:1 by stoecker, 11 years ago

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