Changeset 18652 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2023-02-09T09:47:37+01:00 (20 months ago)
Author:
stoecker
Message:

unify stripUrl() handling

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r18480 r18652  
    130130import org.openstreetmap.josm.tools.MemoryManager.MemoryHandle;
    131131import org.openstreetmap.josm.tools.MemoryManager.NotEnoughMemoryException;
     132import org.openstreetmap.josm.tools.TextUtils;
    132133import org.openstreetmap.josm.tools.Utils;
    133134import org.openstreetmap.josm.tools.bugreport.BugReport;
     
    432433                String url = "";
    433434                try {
    434                     url = tile.getUrl();
     435                    url = TextUtils.stripUrl(tile.getUrl());
    435436                } catch (IOException e) {
    436437                    // silence exceptions
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r18437 r18652  
    3434import org.openstreetmap.josm.io.auth.DefaultAuthenticator;
    3535import org.openstreetmap.josm.spi.preferences.Config;
     36import org.openstreetmap.josm.tools.TextUtils;
    3637
    3738/**
     
    126127
    127128    /**
    128      * Removed privacy related parts form output URL
    129      * @param url Unmodified URL
    130      * @return Stripped URL (privacy related issues removed)
    131      */
    132     private String stripUrl(URL url) {
    133         return url.toString().replaceAll("(token|key|connectId)=[^&]+", "$1=...stripped...");
    134     }
    135 
    136     /**
    137129     * Opens the HTTP connection.
    138130     * @param progressMonitor progress monitor
     
    158150                final boolean hasReason = !Utils.isEmpty(reasonForRequest);
    159151                logRequest("{0} {1}{2} -> {3} {4} ({5}{6})",
    160                         getRequestMethod(), stripUrl(getURL()), hasReason ? (" (" + reasonForRequest + ')') : "",
     152                        getRequestMethod(), TextUtils.stripUrl(getURL().toString()), hasReason ? (" (" + reasonForRequest + ')') : "",
    161153                        cr.getResponseVersion(), cr.getResponseCode(),
    162154                        stopwatch,
     
    176168                }
    177169            } catch (IOException | RuntimeException e) {
    178                 logRequest("{0} {1} -> !!! ({2})", requestMethod, stripUrl(url), stopwatch);
     170                logRequest("{0} {1} -> !!! ({2})", requestMethod, TextUtils.stripUrl(url.toString()), stopwatch);
    179171                Logging.warn(e);
    180172                //noinspection ThrowableResultOfMethodCallIgnored
  • trunk/src/org/openstreetmap/josm/tools/TextUtils.java

    r16541 r18652  
    2121        return url.replace("/", "/\u200b").replace("&", "&\u200b");
    2222    }
     23
     24    /**
     25     * Remove privacy related parts form output URL
     26     * @param url Unmodified URL
     27     * @return Stripped URL (privacy related issues removed)
     28     * @since 18652
     29     */
     30    public static String stripUrl(String url) {
     31        return url.replaceAll("(token|key|connectId)=[^&]+", "$1=...stripped...");
     32    }
     33
    2334}
Note: See TracChangeset for help on using the changeset viewer.