Better handling of extensions when normalizing links.

For markdown syntax the extension was added to the url multiple times if
the option g:vimwiki_markdown_link_ext was set which is now fixed.
Normalizing links no longer adds the extension to the description field.
This commit is contained in:
Rane Brown 2019-07-17 07:10:47 -06:00
parent 86926b7212
commit 86cad979e5

View File

@ -2061,8 +2061,10 @@ endfunction
function! s:clean_url(url)
" don't use an extension as part of the description
let url = substitute(a:url, '\'.vimwiki#vars#get_wikilocal('ext').'$', '', '')
" remove protocol and tld
let url = substitute(a:url, '^\a\+\d*:', '', '')
let url = substitute(url, '^\a\+\d*:', '', '')
let url = substitute(url, '^//', '', '')
let url = substitute(url, '^\([^/]\+\)\.\a\{2,4}/', '\1/', '')
let url_l = split(url, '/\|=\|-\|&\|?\|\.')
@ -2090,8 +2092,12 @@ endfunction
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template)
let url = matchstr(a:str, a:rxUrl)
if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' && vimwiki#vars#get_global('markdown_link_ext')
" strip the extension if it exists so it doesn't get added multiple times
let url = substitute(url, '\'.vimwiki#vars#get_wikilocal('ext').'$', '', '')
endif
let descr = matchstr(a:str, a:rxDesc)
if descr == ""
if descr ==# ''
let descr = s:clean_url(url)
endif
let lnk = s:safesubstitute(a:template, '__LinkDescription__', descr, '')