Changeset 11262 in josm for trunk/src


Ignore:
Timestamp:
2016-11-16T13:53:46+01:00 (3 years ago)
Author:
simon04
Message:

fix #13982 - Wrong links to OSM website if different API is used

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r11247 r11262  
    13921392
    13931393    /**
     1394     * Returns the OSM website URL depending on the selected {@link OsmApi}.
     1395     * @return the OSM website URL depending on the selected {@link OsmApi}
     1396     */
     1397    private static String getOSMWebsiteDependingOnSelectedApi() {
     1398        final String api = OsmApi.getOsmApi().getServerUrl();
     1399        if (OsmApi.DEFAULT_API_URL.equals(api)) {
     1400            return getOSMWebsite();
     1401        } else {
     1402            return api.replaceAll("/api$", "");
     1403        }
     1404    }
     1405
     1406    /**
    13941407     * Replies the base URL for browsing information about a primitive.
    13951408     * @return the base URL, i.e. https://www.openstreetmap.org
     
    13981411    public static String getBaseBrowseUrl() {
    13991412        if (Main.pref != null)
    1400             return Main.pref.get("osm-browse.url", getOSMWebsite());
    1401         return getOSMWebsite();
     1413            return Main.pref.get("osm-browse.url", getOSMWebsiteDependingOnSelectedApi());
     1414        return getOSMWebsiteDependingOnSelectedApi();
    14021415    }
    14031416
     
    14091422    public static String getBaseUserUrl() {
    14101423        if (Main.pref != null)
    1411             return Main.pref.get("osm-user.url", getOSMWebsite() + "/user");
    1412         return getOSMWebsite() + "/user";
     1424            return Main.pref.get("osm-user.url", getOSMWebsiteDependingOnSelectedApi() + "/user");
     1425        return getOSMWebsiteDependingOnSelectedApi() + "/user";
    14131426    }
    14141427
  • trunk/src/org/openstreetmap/josm/io/OsmServerHistoryReader.java

    r10212 r11262  
    6161        try {
    6262            progressMonitor.indeterminateSubTask(tr("Contacting OSM Server..."));
    63             StringBuilder sb = new StringBuilder();
    64             sb.append(primitiveType.getAPIName())
    65             .append('/').append(id).append("/history");
     63            final String urlStr = primitiveType.getAPIName() + '/' + id + "/history";
    6664
    67             try (InputStream in = getInputStream(sb.toString(), progressMonitor.createSubTaskMonitor(1, true))) {
     65            try (InputStream in = getInputStream(urlStr, progressMonitor.createSubTaskMonitor(1, true))) {
    6866                if (in == null)
    6967                    return null;
Note: See TracChangeset for help on using the changeset viewer.