Changeset 18378 in josm for trunk/src/org


Ignore:
Timestamp:
2022-02-09T22:40:12+01:00 (3 years ago)
Author:
taylor.smock
Message:

see #21850: Fix calls to JOSM server where not apikey is needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryPatterns.java

    r18371 r18378  
    9393    static String handleApiKeyTemplate(final String id, final String url) {
    9494        if (id != null && url != null) {
    95             try {
    96                 final String apiKey = FeatureAdapter.retrieveApiKey(id);
    97                 return PATTERN_API_KEY.matcher(url).replaceAll(apiKey);
    98             } catch (IOException | NullPointerException e) {
    99                 // Match rough behavior in JMapViewer TemplatedTMSTileSource, but with better error message.
    100                 throw new IllegalArgumentException(tr("Could not retrieve API key for imagery with id={0}. Cannot add layer.", id), e);
     95            final Matcher matcher = PATTERN_API_KEY.matcher(url);
     96            if (matcher.matches()) {
     97                try {
     98                    final String apiKey = FeatureAdapter.retrieveApiKey(id);
     99                    return matcher.replaceAll(apiKey);
     100                } catch (IOException | NullPointerException e) {
     101                    // Match rough behavior in JMapViewer TemplatedTMSTileSource, but with better error message.
     102                    throw new IllegalArgumentException(tr("Could not retrieve API key for imagery with id={0}. Cannot add layer.", id), e);
     103                }
    101104            }
    102105        }
Note: See TracChangeset for help on using the changeset viewer.