mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
make-uri: Ensure correct number of slashes in file URI.
This commit is contained in:
@@ -413,11 +413,14 @@
|
||||
(string->char-set ":/?#[]@") ;gen-delims
|
||||
(string->char-set "-._~")))
|
||||
|
||||
;;path must be absolute. On Windows an absolute path begins with a
|
||||
;;drive letter followed by a colon.
|
||||
(define (make-uri path)
|
||||
(string-append
|
||||
"file://"
|
||||
(uri-encode (gnc:substring-replace path "\\" "/")
|
||||
(let ((uri-path (uri-encode (gnc:substring-replace path "\\" "/")
|
||||
#:unescaped-chars unreserved-chars-rfc3986)))
|
||||
(string-append
|
||||
(if (char=? (string-ref uri-path 0) #\/) "file://" "file:///")
|
||||
uri-path)))
|
||||
|
||||
(define (gnc:html-js-include file)
|
||||
(format #f
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
(test-begin "test-html-includes")
|
||||
|
||||
(test-equal "windows path into rfc3986 uri"
|
||||
"file://C:/Program%20Files%20%28x86%29/gnucash/share/gnucash/chartjs/Chart.bundle.min.js"
|
||||
"file:///C:/Program%20Files%20%28x86%29/gnucash/share/gnucash/chartjs/Chart.bundle.min.js"
|
||||
(make-uri "C:\\Program Files (x86)\\gnucash/share\\gnucash\\chartjs/Chart.bundle.min.js"))
|
||||
|
||||
(test-end "test-html-includes"))
|
||||
|
||||
Reference in New Issue
Block a user