Changeset 4467 in josm


Ignore:
Timestamp:
Sep 26, 2011 12:19:14 PM (20 months ago)
Author:
simon04
Message:

WMS: make GetCapabilities more robust concerning missing trailing ? or &

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/AddWMSLayerPanel.java

    r4466 r4467  
    307307            if (!Pattern.compile(".*GetCapabilities.*", Pattern.CASE_INSENSITIVE).matcher(serviceUrlStr).matches()) { 
    308308                // If the url doesn't already have GetCapabilities, add it in 
    309                 getCapabilitiesUrl = new URL(serviceUrlStr + "VERSION=1.1.1&SERVICE=WMS&REQUEST=GetCapabilities"); 
     309                getCapabilitiesUrl = new URL(serviceUrlStr); 
     310                final String getCapabilitiesQuery = "VERSION=1.1.1&SERVICE=WMS&REQUEST=GetCapabilities"; 
     311                if (getCapabilitiesUrl.getQuery() == null) { 
     312                    getCapabilitiesUrl = new URL(serviceUrlStr + "?" + getCapabilitiesQuery); 
     313                } else if (!getCapabilitiesUrl.getQuery().isEmpty() && !getCapabilitiesUrl.getQuery().endsWith("&")) { 
     314                    getCapabilitiesUrl = new URL(serviceUrlStr + "&" + getCapabilitiesQuery); 
     315                } else { 
     316                    getCapabilitiesUrl = new URL(serviceUrlStr + getCapabilitiesQuery); 
     317                } 
    310318            } else { 
    311319                // Otherwise assume it's a good URL and let the subsequent error 
Note: See TracChangeset for help on using the changeset viewer.