Should we also check for "//" in the String to prevent something like "hdfs:test.jar"?
Something like: s.matches("(.+)://([^/]+)jar")

Tried with REPL:
val s = "hdfs://test.jar"
  s: java.lang.String = hdfs://test.jar
s.matches("(.+)://([^/]+)jar")
  res3: Boolean = true
s.matches("(.+):(.+)jar")
  res4: Boolean = true
val s2 = "hdfs:test.jar"
  s2: java.lang.String = hdfs:test.jar
s2.matches("(.+)://(.+)jar")
  res5: Boolean = false
s2.matches("(.+):(.+)jar")
  res6: Boolean = true

We do not want dfs:test.jar to be true.