summaryrefslogtreecommitdiff
path: root/autoload/ale/uri.vim
blob: 934637d91c4971765d552d0f6d7ccf14a5609c34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
" This probably doesn't handle Unicode characters well.
function! ale#uri#Encode(value) abort
    return substitute(
    \   a:value,
    \   '\([^a-zA-Z0-9\\/$\-_.!*''(),]\)',
    \   '\=printf(''%%%02x'', char2nr(submatch(1)))',
    \   'g'
    \)
endfunction

function! ale#uri#Decode(value) abort
    return substitute(
    \   a:value,
    \   '%\(\x\x\)',
    \   '\=nr2char(''0x'' . submatch(1))',
    \   'g'
    \)
endfunction