mirror of
https://github.com/fafhrd91/actix-web
synced 2025-08-29 00:07:48 +02:00
fix router cannot parse Non-ASCII characters in URL #137
This commit is contained in:
@@ -4,6 +4,7 @@ use std::hash::{Hash, Hasher};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use regex::{Regex, escape};
|
||||
use percent_encoding::percent_decode;
|
||||
|
||||
use error::UrlGenerationError;
|
||||
use param::Params;
|
||||
@@ -70,9 +71,10 @@ impl Router {
|
||||
}
|
||||
let path: &str = unsafe{mem::transmute(&req.path()[self.0.prefix_len..])};
|
||||
let route_path = if path.is_empty() { "/" } else { path };
|
||||
let p = percent_decode(route_path.as_bytes()).decode_utf8().unwrap();
|
||||
|
||||
for (idx, pattern) in self.0.patterns.iter().enumerate() {
|
||||
if pattern.match_with_params(route_path, req.match_info_mut()) {
|
||||
if pattern.match_with_params(p.as_ref(), req.match_info_mut()) {
|
||||
return Some(idx)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user