Changeset 12090 in josm for trunk


Ignore:
Timestamp:
2017-05-08T22:03:16+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #14756 - Download dialog should also parse URLs which dont contain "#map="

Location:
trunk
Files:
2 edited

Legend:

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

    r11847 r12090  
    4747        if (b != null)
    4848            return b;
    49         if (url.contains("#map")) {
     49        if (url.contains("#map") || url.contains("/#")) {
    5050            // probably it's a URL following the new scheme?
    5151            return parseHashURLs(url);
     
    9595     */
    9696    private static Bounds parseHashURLs(String url) {
    97         int startIndex = url.indexOf("#map=");
     97        int startIndex = url.indexOf('#');
    9898        if (startIndex == -1) return null;
    9999        int endIndex = url.indexOf('&', startIndex);
    100100        if (endIndex == -1) endIndex = url.length();
    101         String coordPart = url.substring(startIndex+5, endIndex);
     101        String coordPart = url.substring(startIndex+(url.contains("#map=") ? "#map=".length() : "#".length()), endIndex);
    102102        String[] parts = coordPart.split("/");
    103103        if (parts.length < 3) {
  • trunk/test/unit/org/openstreetmap/josm/tools/OsmUrlToBoundsTest.java

    r11329 r12090  
    7373        new ParseTestItem("https://www.openstreetmap.org/#map", null),
    7474        new ParseTestItem("https://www.openstreetmap.org/#map=foo", null),
    75         new ParseTestItem("https://www.openstreetmap.org/#map=fooz/foolat/foolon", null)
     75        new ParseTestItem("https://www.openstreetmap.org/#map=fooz/foolat/foolon", null),
     76        new ParseTestItem("http://tyrasd.github.io/latest-changes/#13/51.6891/10.2312",
     77                OsmUrlToBounds.positionToBounds(51.6891, 10.2312, 13))
    7678    };
    7779
Note: See TracChangeset for help on using the changeset viewer.