From 77c56f2ca5cef0aa595756954a544d59523482ab Mon Sep 17 00:00:00 2001 From: Yongqian Li Date: Thu, 20 Apr 2017 01:55:43 -0700 Subject: [PATCH 1/2] update some dependencies --- Cargo.toml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 89620a9a..46d56ad5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pencil" -version = "0.3.0" +version = "0.4.0" authors = ["Shipeng Feng "] keywords = ["web", "framework"] license = "BSD-3-Clause" @@ -10,24 +10,20 @@ homepage = "https://github.com/fengsp/pencil" documentation = "http://fengsp.github.io/pencil/" description = "A micro web framework for Rust." -[features] -default = ["ssl"] -ssl = ["hyper/ssl", "formdata/ssl"] - [dependencies] -regex = "0.1.77" +regex = "0.1" rustc-serialize = "0.3.19" url = "1.2.1" log = "0.3.6" -handlebars = "0.16.1" +handlebars = "0.25" typemap = "0.3.3" mime = "0.2.2" mime_guess = "1.8.0" [dependencies.hyper] -version = "0.9.10" +version = "0.10" default_features = false [dependencies.formdata] -version = "0.11.0" +version = "0.12" default_features = false From 8051f41bbe398b6732c877fe5ef49758adbe8a83 Mon Sep 17 00:00:00 2001 From: Yongqian Li Date: Thu, 20 Apr 2017 02:13:09 -0700 Subject: [PATCH 2/2] update regex to 0.2 --- Cargo.toml | 2 +- src/routing.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 46d56ad5..d4f0e7df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "http://fengsp.github.io/pencil/" description = "A micro web framework for Rust." [dependencies] -regex = "0.1" +regex = "0.2" rustc-serialize = "0.3.19" url = "1.2.1" log = "0.3.6" diff --git a/src/routing.rs b/src/routing.rs index 6c0b04ca..73e19a54 100644 --- a/src/routing.rs +++ b/src/routing.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use std::collections::HashSet; use regex::Regex; -use regex::quote as regex_quote; +use regex::escape as regex_escape; use hyper::method::Method; @@ -33,11 +33,11 @@ fn parse_rule(rule: &str) -> Vec<(Option<&str>, &str)> { Some(caps) => { let static_part = caps.name("static"); if static_part.is_some() { - rule_parts.push((None, static_part.unwrap())); + rule_parts.push((None, static_part.unwrap().as_str())); } - let variable = caps.name("variable").unwrap(); + let variable = caps.name("variable").unwrap().as_str(); let converter = match caps.name("converter") { - Some(converter) => { converter }, + Some(converter) => { converter.as_str() }, None => { "default" }, }; if used_names.contains(variable) { @@ -45,7 +45,7 @@ fn parse_rule(rule: &str) -> Vec<(Option<&str>, &str)> { } used_names.insert(variable); rule_parts.push((Some(converter), variable)); - let end = caps.pos(0).unwrap().1; + let end = caps.get(0).unwrap().end(); let (_, tail) = remaining.split_at(end); remaining = tail; }, @@ -115,7 +115,7 @@ impl<'a> From<&'a str> for Matcher { regex_parts.push(format!("(?P<{}>{})", variable, re)); }, None => { - let escaped_variable = regex_quote(variable); + let escaped_variable = regex_escape(variable); regex_parts.push(escaped_variable); } } @@ -202,7 +202,7 @@ impl Rule { match self.matcher.regex.captures(&path) { Some(caps) => { if let Some(suffix) = caps.name("__suffix__") { - if suffix.is_empty() { + if suffix.as_str().is_empty() { return Some(Err(RequestSlashError)); } } @@ -210,7 +210,7 @@ impl Rule { for variable in self.matcher.regex.capture_names() { if let Some(variable) = variable { if variable != "__suffix__" { - view_args.insert(variable.to_string(), caps.name(variable).unwrap().to_string()); + view_args.insert(variable.to_string(), caps.name(variable).unwrap().as_str().to_string()); } } }