File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## master (unreleased)
4
4
5
+ ### Bugs fixed
6
+
7
+ * [ #83 ] ( https://github.com/clojure-emacs/orchard/pull/83 ) : Ignore non file URLs when checking for directory or file extensions.
8
+
5
9
## 0.5.6 (2020-02-14)
6
10
7
11
### Bugs fixed
Original file line number Diff line number Diff line change 20
20
[]
21
21
(not (nil? (boot-fake-classpath ))))
22
22
23
+ (defn url?
24
+ " Check whether the argument is an url"
25
+ [u]
26
+ (instance? java.net.URL u))
27
+
23
28
(defn directory?
24
- " Whether the argument is a directory"
29
+ " Whether the argument is a directory or an url that points to a directory "
25
30
[f]
26
- (.isDirectory (io/as-file f)))
31
+ (if (url? f)
32
+ (and (= (.getProtocol ^java.net.URL f) " file" )
33
+ (.isDirectory (io/as-file f)))
34
+ (.isDirectory (io/as-file f))))
27
35
28
36
(defn file-ext?
29
37
" Whether the argument's path ends in one of the specified case-insensitive
30
38
file extensions"
31
39
[f & exts]
32
- (let [file (io/as-file f)]
40
+ (when-let [file (if (url? f)
41
+ (when (= (.getProtocol ^java.net.URL f) " file" )
42
+ (io/as-file f))
43
+ (io/as-file f))]
33
44
(some (fn [ext]
34
45
(.endsWith (.. file getName toLowerCase) ext))
35
46
exts)))
Original file line number Diff line number Diff line change 57
57
(is (nil? (misc/namespace-sym nil )))
58
58
(is (= 'unqualified (misc/namespace-sym 'unqualified)))
59
59
(is (= 'qualified (misc/namespace-sym 'qualified/sym))))
60
+
61
+ (deftest file-ext?
62
+ (is (misc/file-ext? (java.net.URL. " file:/tmp/foo.jar" ) " .jar" ))
63
+ (is (not (misc/file-ext? (java.net.URL. " file:/tmp/foo.war" ) " .jar" )))
64
+ (is (not (misc/file-ext? (java.net.URL. " jar:file:/tmp/foo.jar!/BOOT-INF/lib/test.jar" ) " .jar" ))))
65
+
66
+ (deftest directory?
67
+ (is (misc/directory? (.toURL (.toURI (java.io.File. " " ))))))
You can’t perform that action at this time.
0 commit comments