问题描述
使用 CL (SBCL) 和 Puri 库,我获得了 Slime 的 REPL:
CL-USER> (puri:uri-parsed-path (puri:parse-uri "http://www.gnu.org/software/emacs/manual/html_node/emacs/index.html"))
(:ABSOLUTE "software" "emacs" "manual" "html_node" "emacs" "index.html")
我正在尝试使用 Quri 而不是 Puri 来实现相同的输出(包含 URL 路径中拆分词的列表)。
不幸的是,我没有实现它。我试过quri-parse-path
:
CL-USER> quri-object
#<QURI.URI.HTTP:URI-HTTP http://www.gnu.org/software/emacs/>
CL-USER> (quri:parse-path (quri:uri-path quri-object))
"/software/emacs/"
0
16
库是否已经支持此操作?
我不确定是否只能通过阅读 Quri 的文档来实现。不过,我仍然是 CL 的菜鸟。
解决方法
我建议获取uri路径,并用“/”分割:
(quri:uri "http://www.gnu.org/software/emacs/manual/html_node/emacs/index.html")
#<QURI.URI.HTTP:URI-HTTP http://www.gnu.org/software/emacs/manual/html_node/emacs/index.html>
(quri:uri-path *)
"/software/emacs/manual/html_node/emacs/index.html"
(ql:quickload "str")
(str:split "/" * :omit-nulls t)
("software" "emacs" "manual" "html_node" "emacs" "index.html")