mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
net.urllib module
This commit is contained in:

committed by
Alexander Medvednikov

parent
0197f20d47
commit
d3c89273e8
23
vlib/net/urllib/urllib_test.v
Normal file
23
vlib/net/urllib/urllib_test.v
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
|
||||
// Use of this source code is governed by an MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
import net.urllib
|
||||
|
||||
fn test_new_urllib() {
|
||||
test_query := 'Hellö Wörld@vlang'
|
||||
assert urllib.query_escape(test_query) == 'Hell%C3%B6+W%C3%B6rld%40vlang'
|
||||
|
||||
test_url := 'https://joe:pass@www.mydomain.com:8080/som/url?param1=test1¶m2=test2&foo=bar#testfragment'
|
||||
u := urllib.parse(test_url) or {
|
||||
assert false
|
||||
return
|
||||
}
|
||||
assert u.scheme == 'https' &&
|
||||
u.hostname() == 'www.mydomain.com' &&
|
||||
u.port() == '8080' &&
|
||||
u.path == '/som/url' &&
|
||||
u.fragment == 'testfragment' &&
|
||||
u.user.username == 'joe' &&
|
||||
u.user.password == 'pass'
|
||||
}
|
Reference in New Issue
Block a user