Skip to content

Commit ab3b765

Browse files
authored
Merge pull request #841 from mikoto2000/fix-web-http-request-output-file-use-home
2 parents d1937dc + 84c7902 commit ab3b765

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

autoload/vital/__vital__/Web/HTTP.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function! s:_tempname() abort
176176
endfunction
177177

178178
function! s:_file_resolve(file) abort
179-
return fnamemodify(a:file, ':gs?\\?/?')
179+
return fnamemodify(a:file, ':p:gs?\\?/?')
180180
endfunction
181181

182182
function! s:_postdata(data) abort

test/Web/HTTP.vimspec

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,33 @@ Describe Web.HTTP
5252
endfor
5353
End
5454
End
55+
56+
Describe .request()
57+
It client curl
58+
let current_dir = fnamemodify(getcwd(), ":gs?\\?/?")
59+
let response = HTTP.request({
60+
\ 'url': 'file:///' .. current_dir .. '/test/_testdata/Web/test.html',
61+
\ 'client': ['curl'],
62+
\ })
63+
64+
Assert Equals(response.content, "テスト\n")
65+
End
66+
67+
It option_outputFile
68+
let current_dir = fnamemodify(getcwd(), ":gs?\\?/?")
69+
let output_file = tempname()
70+
let response = HTTP.request({
71+
\ 'url': 'file:///' .. current_dir .. '/test/_testdata/Web/test.html',
72+
\ 'outputFile': output_file,
73+
\ 'client': ['curl'],
74+
\ })
75+
76+
let output_file_content = readfile(output_file)
77+
78+
Assert Equals(len(output_file_content), 1)
79+
Assert Equals(output_file_content[0], "テスト")
80+
81+
call delete(output_file)
82+
End
83+
End
5584
End

test/_testdata/Web/test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
テスト

0 commit comments

Comments
 (0)