Changeset 16606 in josm


Ignore:
Timestamp:
2020-06-11T20:03:41+02:00 (8 weeks ago)
Author:
simon04
Message:

see #19320 - Fix URL encoding for taghistory.raifer.tech

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TaginfoAction.java

    r16604 r16606  
    7474            if (tagTable.getSelectedRowCount() == 1) {
    7575                final int row = tagTable.getSelectedRow();
    76                 final String key = Utils.encodeUrl(tagKeySupplier.apply(row)).replaceAll("\\+", "%20");
     76                final String key = tagKeySupplier.apply(row);
    7777                Map<String, Integer> values = tagValuesSupplier.apply(row);
    7878                String value = values.size() == 1 ? values.keySet().iterator().next() : null;
     
    112112    public String getTaginfoUrlForTag(Tag tag) {
    113113        if (tag.getValue().isEmpty()) {
    114             return taginfoUrl + "/keys/" + tag.getKey();
     114            return taginfoUrl + "/keys/" + encodeKeyValue(tag.getKey());
    115115        } else {
    116             return taginfoUrl + "/tags/" + tag.getKey() + '=' + Utils.encodeUrl(tag.getValue()).replaceAll("\\+", "%20");
     116            return taginfoUrl + "/tags/" + encodeKeyValue(tag.getKey()) + '=' + encodeKeyValue(tag.getValue());
    117117        }
     118    }
     119
     120    private static String encodeKeyValue(String string) {
     121        return Utils.encodeUrl(string).replaceAll("\\+", "%20");
    118122    }
    119123
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/TaginfoActionTest.java

    r16597 r16606  
    3131        assertEquals("https://taginfo.openstreetmap.org/keys/railway", action.getTaginfoUrlForTag(new Tag("railway")));
    3232        assertEquals("https://taginfo.openstreetmap.org/tags/railway=tram", action.getTaginfoUrlForTag(new Tag("railway", "tram")));
     33        assertEquals("https://taginfo.openstreetmap.org/tags/addr%3Acity=Bassum%3ACity",
     34                action.getTaginfoUrlForTag(new Tag("addr:city", "Bassum:City")));
    3335        assertEquals("https://taginfo.openstreetmap.org/relations/route", action.getTaginfoUrlForRelationType("route"));
    3436    }
     
    4850     */
    4951    @Test
    50     public void testTagHistoryUrls() {
     52    public void testTagHistoryUrls() throws Exception {
    5153        TaginfoAction action = new TaginfoAction(() -> null, () -> null).toTagHistoryAction();
    5254        assertEquals("https://taghistory.raifer.tech/#***/railway/", action.getTaginfoUrlForTag(new Tag("railway")));
    5355        assertEquals("https://taghistory.raifer.tech/#***/railway/tram", action.getTaginfoUrlForTag(new Tag("railway", "tram")));
     56        assertEquals("https://taghistory.raifer.tech/#***/addr:city/Bassum:City",
     57                action.getTaginfoUrlForTag(new Tag("addr:city", "Bassum:City")));
    5458        assertNull(action.getTaginfoUrlForRelationType("route"));
    5559    }
Note: See TracChangeset for help on using the changeset viewer.