Skip to content

Commit

Permalink
refactor(uri): Add default path for absolute-form
Browse files Browse the repository at this point in the history
Add default path ("/") for absolute-form, even if not included.

This change assumes self.scheme().is_some() indicates that the Uri
is in absolute-form.

Issue:
hyperium#1022
  • Loading branch information
M3rs committed Jan 22, 2017
1 parent 55d13a9 commit 37b26e2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ impl Uri {
let end = self.source.len() - if query_len > 0 { query_len + 1 } else { 0 } -
if fragment_len > 0 { fragment_len + 1 } else { 0 };
if index >= end {
if self.scheme().is_some() {
return "/" // absolute-form MUST have path
}
""
} else {
&self.source[index..end]
Expand Down Expand Up @@ -317,7 +320,7 @@ test_parse! {
"http://127.0.0.1:80",

scheme = Some("http"),
authority = Some("127.0.0.1"),
authority = Some("127.0.0.1:80"),
path = "/",
query = None,
fragment = None,
Expand All @@ -328,7 +331,7 @@ test_parse! {
"https://127.0.0.1:443",

scheme = Some("https"),
authority = Some("127.0.0.1"),
authority = Some("127.0.0.1:443"),
path = "/",
query = None,
fragment = None,
Expand Down

0 comments on commit 37b26e2

Please sign in to comment.