]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/gui/map/MapSource.java
Version 18, July 2015
[GpsPrune.git] / tim / prune / gui / map / MapSource.java
index 88ab85aa5e11eb4f45b22c4a0e4cc20ce7708a03..b7a08fcf8d7d19b2314129ed66900b06bc01f460 100644 (file)
@@ -84,13 +84,19 @@ public abstract class MapSource
        {
                if (inUrl == null || inUrl.equals("")) {return null;}
                String urlstr = inUrl;
+               boolean urlOk = false;
+
                // check prefix
-               try {
-                       new URL(urlstr.replace('[', 'w').replace(']', 'w'));
-                       // There's a warning that this URL object isn't used, but it's enough to know the parse
-                       // was successful without an exception being thrown.
+               try
+               {
+                       urlOk = new URL(urlstr.replace('[', 'w').replace(']', 'w')) != null;
                }
                catch (MalformedURLException e)
+               {
+                       urlOk = false;
+               }
+
+               if (!urlOk)
                {
                        // fail if protocol specified
                        if (urlstr.indexOf("://") >= 0) {return null;}
@@ -102,7 +108,8 @@ public abstract class MapSource
                        urlstr = urlstr + "/";
                }
                // Validate current url, return null if not ok
-               try {
+               try
+               {
                        URL url = new URL(urlstr.replace('[', 'w').replace(']', 'w'));
                        // url host must contain a dot
                        if (url.getHost().indexOf('.') < 0) {return null;}