Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Add protocol determinate function for HTTP

AuthorDaveJarvis <email>
Date2020-09-12 12:37:48 GMT-0700
Commit92debb6a11545680da1fb6cdfeb7a4f31f60eaf7
Parent11f3591
Delta13 lines added, 0 lines removed, 13-line increase
src/main/java/com/scrivenvar/util/ProtocolResolver.java
*/
public class ProtocolResolver {
+ public static final String SCHEME_HTTP = "http";
+
+ /**
+ * Answers {@code true} if the given protocol is either HTTP or HTTPS.
+ *
+ * @param protocol The protocol to compare against the web protocol.
+ * @return {@code true} the protocol is either HTTP or HTTPS.
+ */
+ public static boolean isHttp( String protocol ) {
+ protocol = protocol == null ? "" : protocol;
+ return protocol.toLowerCase().startsWith( SCHEME_HTTP );
+ }
+
/**
* Returns the protocol for a given URI or filename.