// almost finally check the startup file arguments
for (String f : _startupFiles) {
- _appargs.add(HttpUtils.startsWithHttpOrHttpsOrJalviewScheme(f)?f:new File(f).getAbsolutePath());
+ _appargs.add(HttpUtils.isPlausibleUri(f)?f:new File(f).getAbsolutePath());
}
// check if one arg with recognised extension
{
public final static String JALVIEWSCHEMEPREFIX = "jalview";
+ public static boolean isPlausibleUri(String s)
+ {
+ if (s == null)
+ {
+ return false;
+ }
+ if (startsWithHttpOrHttps(s) || isJalviewSchemeUri(s))
+ {
+ return true;
+ }
+ try
+ {
+ URI u = new URI(s);
+ // allow file:/home/... as well as file:///home... as java copes
+ if (s.startsWith("file:/"))
+ {
+ return true;
+ }
+ } catch (URISyntaxException e)
+ {
+ return false;
+ }
+ return false;
+ }
+
/**
* Returns true if it is possible to open an input stream at the given URL,
* else false. The input stream is closed.
return file.startsWith("http://") || file.startsWith("https://");
}
- public static boolean startsWithHttpOrHttpsOrJalviewScheme(String file)
- {
- if (startsWithHttpOrHttps(file))
- {
- return true;
- }
- return isJalviewSchemeUri(file);
- }
-
/**
* wrapper to get/post to a URL or check headers
*
{
public final static String JALVIEWSCHEMEPREFIX = "jalview";
+ public static boolean isPlausibleUri(String s)
+ {
+ if (s == null)
+ {
+ return false;
+ }
+ if (startsWithHttpOrHttps(s) || isJalviewSchemeUri(s))
+ {
+ return true;
+ }
+ try
+ {
+ URI u = new URI(s);
+ // allow file:/home/... as well as file:///home... as java copes
+ if (s.startsWith("file:/"))
+ {
+ return true;
+ }
+ } catch (URISyntaxException e)
+ {
+ return false;
+ }
+ return false;
+ }
+
/**
* Returns true if it is possible to open an input stream at the given URL,
* else false. The input stream is closed.
return file.startsWith("http://") || file.startsWith("https://");
}
- public static boolean startsWithHttpOrHttpsOrJalviewScheme(String file)
- {
- if (startsWithHttpOrHttps(file))
- {
- return true;
- }
- return isJalviewSchemeUri(file);
- }
-
/**
* wrapper to get/post to a URL or check headers
*