Skip to content

Commit bb70703

Browse files
committed
upgrade url to 1.2
This was a bit involved, but wasn't too bad, thanks to @simonspain's work here: https://github.com/servo/rust-url/blob/master/UPGRADING.md
1 parent 1c7e678 commit bb70703

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ time = "0.1"
2323
git2 = "0.4"
2424
flate2 = "0.2"
2525
semver = "0.2"
26-
url = "0.5.0"
26+
url = "1.2.1"
2727
postgres = { version = "0.11", features = ["time"] }
2828
r2d2 = "0.6.0"
2929
r2d2_postgres = "0.10"

src/krate.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_serialize::hex::ToHex;
1818
use rustc_serialize::json;
1919
use semver;
2020
use time::{Timespec, Duration};
21-
use url::{self, Url};
21+
use url::Url;
2222

2323
use {Model, User, Keyword, Version};
2424
use app::{App, RequestApp};
@@ -182,17 +182,14 @@ impl Crate {
182182
let url = try!(Url::parse(url).map_err(|_| {
183183
human(format!("`{}` is not a valid url: `{}`", field, url))
184184
}));
185-
match &url.scheme[..] {
185+
match &url.scheme()[..] {
186186
"http" | "https" => {}
187187
s => return Err(human(format!("`{}` has an invalid url \
188188
scheme: `{}`", field, s)))
189189
}
190-
match url.scheme_data {
191-
url::SchemeData::Relative(..) => {}
192-
url::SchemeData::NonRelative(..) => {
193-
return Err(human(format!("`{}` must have relative scheme \
194-
data: {}", field, url)))
195-
}
190+
if url.cannot_be_a_base() {
191+
return Err(human(format!("`{}` must have relative scheme \
192+
data: {}", field, url)))
196193
}
197194
Ok(())
198195
}

src/util/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ impl<'a> RequestUtils for Request + 'a {
7878
fn query(&self) -> HashMap<String, String> {
7979
url::form_urlencoded::parse(self.query_string().unwrap_or("")
8080
.as_bytes())
81-
.into_iter().collect()
81+
.map(|(a, b)| (a.into_owned(), b.into_owned()))
82+
.collect()
8283
}
8384

8485
fn redirect(&self, url: String) -> Response {

src/version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub fn index(req: &mut Request) -> CargoResult<Response> {
225225
// Extract all ids requested.
226226
let query = url::form_urlencoded::parse(req.query_string().unwrap_or("")
227227
.as_bytes());
228-
let ids = query.iter().filter_map(|&(ref a, ref b)| {
228+
let ids = query.filter_map(|(ref a, ref b)| {
229229
if *a == "ids[]" {
230230
b.parse().ok()
231231
} else {

0 commit comments

Comments
 (0)