This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/autoload/ale/uri.vim

18 lines
436 B
VimL

" 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