Changeset 15794 in josm for trunk/src


Ignore:
Timestamp:
2020-01-29T20:58:58+01:00 (5 years ago)
Author:
simon04
Message:

see #13901 - Tag2Link: add http:// to website

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Tag2Link.java

    r15711 r15794  
    137137
    138138        // Common
    139         final boolean valueIsURL = value.matches("^(http:|https:|www\\.).*");
    140         if (key.matches("^(.+[:_])?website([:_].+)?$") && valueIsURL) {
    141             linkConsumer.acceptLink(getLinkName(value, key), value);
     139        final String validURL = value.startsWith("http:") || value.startsWith("https:")
     140                ? value
     141                : value.startsWith("www.")
     142                ? "http://" + value
     143                : null;
     144        if (key.matches("^(.+[:_])?website([:_].+)?$") && validURL != null) {
     145            linkConsumer.acceptLink(getLinkName(validURL, key), validURL);
    142146        }
    143         if (key.matches("^(.+[:_])?source([:_].+)?$") && valueIsURL) {
    144             linkConsumer.acceptLink(getLinkName(value, key), value);
     147        if (key.matches("^(.+[:_])?source([:_].+)?$") && validURL != null) {
     148            linkConsumer.acceptLink(getLinkName(validURL, key), validURL);
    145149        }
    146         if (key.matches("^(.+[:_])?url([:_].+)?$") && valueIsURL) {
    147             linkConsumer.acceptLink(getLinkName(value, key), value);
     150        if (key.matches("^(.+[:_])?url([:_].+)?$") && validURL != null) {
     151            linkConsumer.acceptLink(getLinkName(validURL, key), validURL);
    148152        }
    149         if (key.matches("image") && valueIsURL) {
    150             linkConsumer.acceptLink(tr("View image"), value);
     153        if (key.matches("image") && validURL != null) {
     154            linkConsumer.acceptLink(tr("View image"), validURL);
    151155        }
    152156
Note: See TracChangeset for help on using the changeset viewer.