1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net.urllib: add a URL.debug() method, returning the values of all the URL's fields

This commit is contained in:
Delyan Angelov 2022-09-29 10:34:48 +03:00
parent e2cf403ca1
commit 3b420a8d7f
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -303,13 +303,9 @@ fn escape(s string, mode EncodingMode) string {
}
// A URL represents a parsed URL (technically, a URI reference).
//
// The general form represented is:
//
// [scheme:][//[userinfo@]host][/]path[?query][#fragment]
//
// URLs that do not start with a slash after the scheme are interpreted as:
//
// scheme:opaque[?query][#fragment]
//
// Note that the path field is stored in decoded form: /%47%6f%2f becomes /Go/.
@ -333,6 +329,11 @@ pub mut:
fragment string // fragment for references, without '#'
}
// debug returns a string representation of *ALL* the fields of the given URL
pub fn (url &URL) debug() string {
return 'URL{\n scheme: $url.scheme\n opaque: $url.opaque\n user: $url.user\n host: $url.host\n path: $url.path\n raw_path: $url.raw_path\n force_query: $url.force_query\n raw_query: $url.raw_query\n fragment: $url.fragment\n}'
}
// user returns a Userinfo containing the provided username
// and no password set.
pub fn user(username string) &Userinfo {