Changeset 16774 in josm


Ignore:
Timestamp:
2020-07-15T21:00:18+02:00 (4 years ago)
Author:
simon04
Message:

fix #19293 - Tag2link/wikipedia: replace space with underscore

Location:
trunk
Files:
2 edited

Legend:

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

    r16434 r16774  
    156156        if (keyMatcher.matches() && valueMatcher.matches()) {
    157157            final String lang = Utils.firstNotEmptyString("en", keyMatcher.group("lang"), valueMatcher.group("lang"));
    158             linkConsumer.acceptLink(tr("View Wikipedia article"), "https://" + lang + ".wikipedia.org/wiki/" + valueMatcher.group("article"));
     158            final String url = "https://" + lang + ".wikipedia.org/wiki/" + valueMatcher.group("article").replace(' ', '_');
     159            linkConsumer.acceptLink(tr("View Wikipedia article"), url);
    159160        }
    160161        if (key.matches("(.*:)?wikidata")) {
  • trunk/test/unit/org/openstreetmap/josm/tools/Tag2LinkTest.java

    r16434 r16774  
    5252     */
    5353    @Test
     54    public void testWikipedia() {
     55        Tag2Link.getLinksForTag("wikipedia", "de:Wohnhausgruppe Herderstraße", this::addLink);
     56        checkLinks("View Wikipedia article // https://de.wikipedia.org/wiki/Wohnhausgruppe_Herderstraße");
     57        links.clear();
     58        Tag2Link.getLinksForTag("wikipedia", "de:Stadtbahn Köln#Innenstadttunnel", this::addLink);
     59        checkLinks("View Wikipedia article // https://de.wikipedia.org/wiki/Stadtbahn_Köln#Innenstadttunnel");
     60    }
     61
     62    /**
     63     * Unit test of function {@link Tag2Link#getLinksForTag}.
     64     */
     65    @Test
    5466    public void testImageCommonsImage() {
    5567        Tag2Link.getLinksForTag("image", "File:Witten Brücke Gasstraße.jpg", this::addLink);
Note: See TracChangeset for help on using the changeset viewer.