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 `/`.
This commit is contained in:
Patrick Stockwell 2020-05-09 17:35:29 +10:00 committed by Tinmarino
parent 73527d3f14
commit ab301801b0

View File

@ -24,7 +24,8 @@ endif
function! vimwiki#path#normalize(path) abort function! vimwiki#path#normalize(path) abort
let path = a:path let path = a:path
while 1 while 1
let result = substitute(path, '/[^/]\+/\.\.\|\./', '', '') let intermediateResult = substitute(path, '/[^/]\+/\.\.', '', '')
let result = substitute(intermediateResult, '/\./', '/', '')
if result ==# path if result ==# path
break break
endif endif