Skip to content

Commit 8079c71

Browse files
Daniel Pattersonbrson
authored andcommitted
---
yaml --- r: 20847 b: refs/heads/snap-stage3 c: e349201 h: refs/heads/master i: 20845: 6493891 20843: 42c07c0 20839: c7098a9 20831: e63a15e v: v3
1 parent 3bd8a92 commit 8079c71

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: ef46314d1e6418b57a1d0a4efb5853dcaf8077d4
4+
refs/heads/snap-stage3: e349201bc26c2581e948aae53ac7701c34bef80c
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/net_url.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ fn encode_inner(s: ~str, full_url: bool) -> ~str {
7878
}
7979
}
8080

81-
/** Encodes a URI by replacing reserved characters with percent encoded character
81+
/**
82+
* Encodes a URI by replacing reserved characters with percent encoded character
8283
* sequences.
8384
*
8485
* This function is compliant with RFC 3986.
@@ -87,7 +88,8 @@ fn encode(s: ~str) -> ~str {
8788
encode_inner(s, true)
8889
}
8990

90-
/** Encodes a URI component by replacing reserved characters with percent encoded
91+
/**
92+
* Encodes a URI component by replacing reserved characters with percent encoded
9193
* character sequences.
9294
*
9395
* This function is compliant with RFC 3986.
@@ -134,15 +136,17 @@ fn decode_inner(s: ~str, full_url: bool) -> ~str {
134136
}
135137
}
136138

137-
/** Decode a string encoded with percent encoding.
139+
/**
140+
* Decode a string encoded with percent encoding.
138141
*
139142
* This will only decode escape sequences generated by encode_uri.
140143
*/
141144
fn decode(s: ~str) -> ~str {
142145
decode_inner(s, true)
143146
}
144147

145-
/** Decode a string encoded with percent encoding.
148+
/**
149+
* Decode a string encoded with percent encoding.
146150
*/
147151
fn decode_component(s: ~str) -> ~str {
148152
decode_inner(s, false)
@@ -167,7 +171,8 @@ fn encode_plus(s: ~str) -> ~str {
167171
}
168172
}
169173

170-
/** Encode a hashmap to the 'application/x-www-form-urlencoded' media type.
174+
/**
175+
* Encode a hashmap to the 'application/x-www-form-urlencoded' media type.
171176
*/
172177
fn encode_form_urlencoded(m: hashmap<~str, @dvec<@~str>>) -> ~str {
173178
let mut out = ~"";
@@ -191,7 +196,8 @@ fn encode_form_urlencoded(m: hashmap<~str, @dvec<@~str>>) -> ~str {
191196
out
192197
}
193198

194-
/** Decode a string encoded with the 'application/x-www-form-urlencoded' media
199+
/**
200+
* Decode a string encoded with the 'application/x-www-form-urlencoded' media
195201
* type into a hashmap.
196202
*/
197203
fn decode_form_urlencoded(s: ~[u8]) -> hashmap<~str, @dvec<@~str>> {
@@ -415,6 +421,18 @@ impl of to_str::to_str for url {
415421

416422
#[cfg(test)]
417423
mod tests {
424+
#[test]
425+
fn test_url_parse() {
426+
let url = ~"http://user:[email protected]/doc?s=v#something";
427+
let u = result::unwrap(from_str(url));
428+
assert u.scheme == ~"http";
429+
assert option::unwrap(u.user).user == ~"user";
430+
assert option::unwrap(option::unwrap(u.user).pass) == ~"pass";
431+
assert u.host == ~"rust-lang.org";
432+
assert u.path == ~"/doc";
433+
assert u.query.get(~"s") == ~"v";
434+
assert option::unwrap(u.fragment) == "something";
435+
}
418436
#[test]
419437
fn test_full_url_parse_and_format() {
420438
let url = ~"http://user:[email protected]/doc?s=v#something";

0 commit comments

Comments
 (0)