Preserve single and double slashes while joining

This commit is contained in:
Samvid Mistry 2023-11-01 13:58:44 +05:30
parent a71b4f5e8d
commit e4ac3f205d
1 changed files with 12 additions and 8 deletions

View File

@ -572,10 +572,14 @@ Or go to the top level if there is none."
This is mu4e's version of Emacs 28's `file-name-concat' with the
difference it also handles slashes at the beginning of
COMPONENTS."
(replace-regexp-in-string
(let ((double-slash (string-match "^//[^/]" directory))
(path (replace-regexp-in-string
"//+" "/"
(mapconcat (lambda (part) (if (stringp part) part ""))
(cons directory components) "/")))
(cons directory components) "/"))))
(if double-slash
(concat "/" path)
path)))
(defun mu4e-string-replace (from-string to-string in-string)
"Replace FROM-STRING with TO-STRING in IN-STRING each time it occurs.