Changeset 17006 in josm


Ignore:
Timestamp:
2020-09-03T21:50:29+02:00 (5 years ago)
Author:
simon04
Message:

fix #19754 - Tag2Link: support multi-values for wikimedia_commons

Location:
trunk
Files:
2 edited

Legend:

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

    r16839 r17006  
    187187        }
    188188        if (key.matches("(.*:)?wikidata")) {
    189             OsmUtils.splitMultipleValues(value)
    190                     .forEach(q -> linkConsumer.acceptLink(tr("View Wikidata item"), "https://www.wikidata.org/wiki/" + q, imageResource.get()));
     189            OsmUtils.splitMultipleValues(value).forEach(q -> linkConsumer.acceptLink(
     190                    tr("View Wikidata item"), "https://www.wikidata.org/wiki/" + q, imageResource.get()));
    191191        }
    192192        if (key.matches("(.*:)?species")) {
     
    195195        }
    196196        if (key.matches("wikimedia_commons|image") && value.matches("(?i:File):.*")) {
    197             String url = "https://commons.wikimedia.org/wiki/" + value;
    198             linkConsumer.acceptLink(tr("View image on Wikimedia Commons"), url, imageResource.get());
     197            OsmUtils.splitMultipleValues(value).forEach(i -> linkConsumer.acceptLink(
     198                    tr("View image on Wikimedia Commons"), "https://commons.wikimedia.org/wiki/" + i, imageResource.get()));
    199199        }
    200200        if (key.matches("wikimedia_commons|image") && value.matches("(?i:Category):.*")) {
    201             String url = "https://commons.wikimedia.org/wiki/" + value;
    202             linkConsumer.acceptLink(tr("View category on Wikimedia Commons"), url, imageResource.get());
     201            OsmUtils.splitMultipleValues(value).forEach(i -> linkConsumer.acceptLink(
     202                    tr("View category on Wikimedia Commons"), "https://commons.wikimedia.org/wiki/" + i, imageResource.get()));
    203203        }
    204204
  • trunk/test/unit/org/openstreetmap/josm/tools/Tag2LinkTest.java

    r16839 r17006  
    8888        Tag2Link.getLinksForTag("image", "File:Witten Brücke Gasstraße.jpg", this::addLink);
    8989        checkLinks("View image on Wikimedia Commons // https://commons.wikimedia.org/wiki/File:Witten Brücke Gasstraße.jpg");
     90        links.clear();
     91        // non-regression test for #19754
     92        Tag2Link.getLinksForTag("image", "File:Foo.jpg;File:Bar.jpg", this::addLink);
     93        checkLinks("View image on Wikimedia Commons // https://commons.wikimedia.org/wiki/File:Foo.jpg",
     94                "View image on Wikimedia Commons // https://commons.wikimedia.org/wiki/File:Bar.jpg");
    9095    }
    9196
Note: See TracChangeset for help on using the changeset viewer.