Changeset 17909 in josm
- Timestamp:
- 2021-05-24T12:13:55+02:00 (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Tag2Link.java
r17736 r17909 27 27 import javax.json.JsonValue; 28 28 29 import com.google.gdata.util.common.base.PercentEscaper;30 29 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 31 30 import org.openstreetmap.josm.data.osm.OsmUtils; … … 218 217 219 218 private static String getWikimediaCommonsUrl(String i) { 220 return "https://commons.wikimedia.org/wiki/" + new PercentEscaper(PercentEscaper.SAFEPATHCHARS_URLENCODER, false).escape(i); 219 i = i.replace(' ', '_'); 220 i = Utils.encodeUrl(i); 221 return "https://commons.wikimedia.org/wiki/" + i; 221 222 } 222 223 -
trunk/test/unit/org/openstreetmap/josm/tools/Tag2LinkTest.java
r17736 r17909 87 87 void testImageCommonsImage() { 88 88 Tag2Link.getLinksForTag("image", "File:Witten Brücke Gasstraße.jpg", this::addLink); 89 checkLinks("View image on Wikimedia Commons // https://commons.wikimedia.org/wiki/File :Witten%20Br%C3%BCcke%20Gasstra%C3%9Fe.jpg");89 checkLinks("View image on Wikimedia Commons // https://commons.wikimedia.org/wiki/File%3AWitten_Br%C3%BCcke_Gasstra%C3%9Fe.jpg"); 90 90 links.clear(); 91 91 // non-regression test for #19754 92 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");93 checkLinks("View image on Wikimedia Commons // https://commons.wikimedia.org/wiki/File%3AFoo.jpg", 94 "View image on Wikimedia Commons // https://commons.wikimedia.org/wiki/File%3ABar.jpg"); 95 95 links.clear(); 96 96 // non-regression test for #19771 … … 98 98 checkLinks("View image on Wikimedia Commons // " + 99 99 "https://commons.wikimedia.org/wiki/" + 100 "File :C%C3%B4te%20de%20granite%20rose%20-%20Tr%C3%A9gastel%20%C3%A0%20Ploumanac'h%20-%2020190723%20-%20025.jpg");100 "File%3AC%C3%B4te_de_granite_rose_-_Tr%C3%A9gastel_%C3%A0_Ploumanac%27h_-_20190723_-_025.jpg"); 101 101 } 102 102 … … 107 107 void testImageCommonsCategory() { 108 108 Tag2Link.getLinksForTag("image", "category:JOSM", this::addLink); 109 checkLinks("View category on Wikimedia Commons // https://commons.wikimedia.org/wiki/category :JOSM");109 checkLinks("View category on Wikimedia Commons // https://commons.wikimedia.org/wiki/category%3AJOSM"); 110 110 } 111 111
Note:
See TracChangeset
for help on using the changeset viewer.