From ab301801b0ad65783b96f110059f19cd935bab97 Mon Sep 17 00:00:00 2001 From: Patrick Stockwell Date: Sat, 9 May 2020 17:35:29 +1000 Subject: [PATCH] Improve path normalisation with separate substitutions This change reverts the original regex and simply adds a second regex which is called on the result. '/\./' is one literal forward slash, one literal fullstop (escaped with a leading backslash), and one literal forward slash. In plain text, `/./` will be replaced with `/`. --- autoload/vimwiki/path.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/vimwiki/path.vim b/autoload/vimwiki/path.vim index 6a7673e..c0ce8eb 100644 --- a/autoload/vimwiki/path.vim +++ b/autoload/vimwiki/path.vim @@ -24,7 +24,8 @@ endif function! vimwiki#path#normalize(path) abort let path = a:path while 1 - let result = substitute(path, '/[^/]\+/\.\.\|\./', '', '') + let intermediateResult = substitute(path, '/[^/]\+/\.\.', '', '') + let result = substitute(intermediateResult, '/\./', '/', '') if result ==# path break endif