Index: /trunk/src/org/openstreetmap/josm/tools/Mediawiki.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Mediawiki.java	(revision 18045)
+++ /trunk/src/org/openstreetmap/josm/tools/Mediawiki.java	(revision 18046)
@@ -95,12 +95,5 @@
     public void searchGeoImages(Bounds bounds, BiConsumer<String, LatLon> imageConsumer)
             throws IOException, ParserConfigurationException, SAXException, XPathExpressionException {
-        final URL url = new URL(baseUrl +
-                "?format=xml" +
-                "&action=query" +
-                "&list=geosearch" +
-                "&gsnamespace=6" +
-                "&gslimit=500" +
-                "&gsprop=type|name" +
-                "&gsbbox=" + bounds.getMaxLat() + "|" + bounds.getMinLon() + "|" + bounds.getMinLat() + "|" + bounds.getMaxLon());
+        final URL url = new URL(getGeoImagesUrl(baseUrl, bounds));
         final Document document = getDocument(url);
         final XPath xPath = XPathFactory.newInstance().newXPath();
@@ -113,4 +106,23 @@
             imageConsumer.accept(title, new LatLon(lat, lon));
         }
+    }
+
+    /**
+     * Returns the URL for searching geolocated images in given bounds.
+     * @param baseUrl The wiki base URL
+     * @param bounds the bounds of the search area
+     * @return the URL for searching geolocated images in given bounds
+     * @since 18046
+     */
+    public static String getGeoImagesUrl(String baseUrl, Bounds bounds) {
+        String sep = Utils.encodeUrl("|");
+        return baseUrl +
+                "?format=xml" +
+                "&action=query" +
+                "&list=geosearch" +
+                "&gsnamespace=6" +
+                "&gslimit=500" +
+                "&gsprop=type" + sep + "name" +
+                "&gsbbox=" + bounds.getMaxLat() + sep + bounds.getMinLon() + sep + bounds.getMinLat() + sep + bounds.getMaxLon();
     }
 
Index: /trunk/test/unit/org/openstreetmap/josm/tools/MediawikiTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/tools/MediawikiTest.java	(revision 18045)
+++ /trunk/test/unit/org/openstreetmap/josm/tools/MediawikiTest.java	(revision 18046)
@@ -4,5 +4,9 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
+import java.net.URI;
+import java.net.URL;
+
 import org.junit.jupiter.api.Test;
+import org.openstreetmap.josm.data.Bounds;
 
 /**
@@ -21,3 +25,15 @@
                 Mediawiki.getImageUrl("https://upload.wikimedia.org/wikipedia/commons/", "OpenJDK_logo.svg"));
     }
+
+    /**
+     * Test of {@link Mediawiki#getGeoImagesUrl}
+     * @throws Exception never
+     */
+    @Test
+    void testGeoImagesUrl() throws Exception {
+        // See https://josm.openstreetmap.de/ticket/21126
+        // Checks that URL can be converted to URI, needed for HTTP/2
+        assertEquals(new URI("https://commons.wikimedia.org/w/api.php?format=xml&action=query&list=geosearch&gsnamespace=6&gslimit=500&gsprop=type%7Cname&gsbbox=48.8623665%7C2.3913497%7C48.8600879%7C2.3967605"),
+                new URL(Mediawiki.getGeoImagesUrl("https://commons.wikimedia.org/w/api.php", new Bounds(48.8600879, 2.3913497, 48.8623665, 2.3967605))).toURI());
+    }
 }
