From 11998b3913ff8f67e1aef6f356e41cd1975ebe19 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 25 May 2019 17:27:56 -0400 Subject: [PATCH] Remove resolver element in path tuple. Try to simplify module/paths back to how it used to be. --- examples/urlloader.janet | 7 ++++--- src/boot/boot.janet | 13 +++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/urlloader.janet b/examples/urlloader.janet index 25163998..75cf82c0 100644 --- a/examples/urlloader.janet +++ b/examples/urlloader.janet @@ -20,9 +20,10 @@ (defn- check-http-url [path] - (or (string/has-prefix? "http://" path) - (string/has-prefix? "https://" path))) + (if (or (string/has-prefix? "http://" path) + (string/has-prefix? "https://" path)) + path)) # Add the module loader and path tuple to right places -(array/push module/paths ["HTTP" :janet-http check-http-url identity]) +(array/push module/paths [check-http-url :janet-http]) (put module/loaders :janet-http load-url) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index b3886adb..c1cbda1d 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -1588,7 +1588,7 @@ require should load files found at these paths.\n\nA tuple can also contain a third element, specifying a filter that prevents module/find from searching that path template if the filter doesn't match the input - path." + path. The filter is often a file extension, including the period." @[[":all:" :source ".janet"] [":all:" :native (if (= (os/which) :windows) ".dll" ".so")] [":all:" :image ".jimage"] @@ -1651,10 +1651,10 @@ (def parts (string/split "/" path)) (def name (last parts)) (var ret nil) - (each [p mod-kind checker resolver] module/paths + (each [p mod-kind checker] module/paths (when (mod-filter checker path) - (if resolver - (when-let [res (resolver path)] + (if (function? p) + (when-let [res (p path)] (set ret [res mod-kind]) (break)) (do @@ -1664,8 +1664,9 @@ (break)))))) (if ret ret (let [expander (fn [[t _ chk]] - (when (mod-filter chk path) - (expand-path-name t name path))) + (when (string? t) + (when (mod-filter chk path) + (expand-path-name t name path)))) paths (filter identity (map expander module/paths)) str-parts (interpose "\n " paths)] [nil (string "could not find module " path ":\n " ;str-parts)])))