~vpzom/trout

9cdef48655d047f3bbd39b2178ab4d79100c5066 — Colin Reeder 1 year, 5 months ago eac7d5f master v0.2.0
Decode URL segments
2 files changed, 14 insertions(+), 9 deletions(-)

M Cargo.toml
M src/node.rs
M Cargo.toml => Cargo.toml +1 -0
@@ 14,6 14,7 @@ default = ["hyper"]

[dependencies]
hyper = { version = "0.13.5", optional = true }
percent-encoding = "2.1.0"

[dev-dependencies]
tokio = { version = "0.2.21", features = ["macros"] }

M src/node.rs => src/node.rs +13 -9
@@ 72,11 72,13 @@ impl<
            None => (path, ""),
        };

        if let Ok(new_param) = seg.parse::<A>() {
            ret.take_return(|(props, req, context)| {
                let props = P2::tuple_add(props, new_param);
                self.0.route_inner(remaining, props, req, context)
            });
        if let Ok(seg) = percent_encoding::percent_decode(seg.as_bytes()).decode_utf8() {
            if let Ok(new_param) = seg.parse::<A>() {
                ret.take_return(|(props, req, context)| {
                    let props = P2::tuple_add(props, new_param);
                    self.0.route_inner(remaining, props, req, context)
                });
            }
        }
    }
}


@@ 93,10 95,12 @@ impl<P1: 'static, R: Request + 'static, T: 'static, C: 'static, P2: TupleAdd<P1,
            None => (path, ""),
        };

        ret.take_return(|(props, req, context)| {
            let props = P2::tuple_add(props, seg.to_owned());
            self.0.route_inner(remaining, props, req, context)
        });
        if let Ok(seg) = percent_encoding::percent_decode(seg.as_bytes()).decode_utf8() {
            ret.take_return(|(props, req, context)| {
                let props = P2::tuple_add(props, seg.into_owned());
                self.0.route_inner(remaining, props, req, context)
            });
        }
    }
}