2020-12-04 16:15:32 -05:00
|
|
|
function! s:EncodeChar(char) abort
|
|
|
|
let l:result = ''
|
|
|
|
|
|
|
|
for l:index in range(strlen(a:char))
|
|
|
|
let l:result .= printf('%%%02x', char2nr(a:char[l:index]))
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:result
|
|
|
|
endfunction
|
|
|
|
|
2018-03-31 10:55:20 -04:00
|
|
|
function! ale#uri#Encode(value) abort
|
|
|
|
return substitute(
|
|
|
|
\ a:value,
|
|
|
|
\ '\([^a-zA-Z0-9\\/$\-_.!*''(),]\)',
|
2020-12-04 16:15:32 -05:00
|
|
|
\ '\=s:EncodeChar(submatch(1))',
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'g'
|
|
|
|
\)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale#uri#Decode(value) abort
|
|
|
|
return substitute(
|
|
|
|
\ a:value,
|
|
|
|
\ '%\(\x\x\)',
|
2020-12-04 16:15:32 -05:00
|
|
|
\ '\=printf("%c", str2nr(submatch(1), 16))',
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'g'
|
|
|
|
\)
|
|
|
|
endfunction
|