Repository: actix/actix-web
File: src/extractor.rs (Rust)

Code before:
        assert_eq!(s.as_ref().key, "name");
        assert_eq!(s.value, 32);

        let s = Path::<(String, u8)>::from_request(&req, &PathConfig::default()).unwrap();
        assert_eq!(s.0, "name");
        assert_eq!(s.1, 32);

        let res = Path::<Vec<String>>::extract(&req).unwrap();
        assert_eq!(res[0], "name".to_owned());
        assert_eq!(res[1], "32".to_owned());
    }

    #[test]
    fn test_extract_path_single() {
        let mut router = Router::<()>::default();
        router.register_resource(Resource::new(ResourceDef::new("/{value}/")));

        let req = TestRequest::with_uri("/32/").finish();
        let info = router.recognize(&req, &(), 0);
        let req = req.with_route_info(info);
        assert_eq!(*Path::<i8>::from_request(&req, &&PathConfig::default()).unwrap(), 32);
    }

    #[test]
    fn test_extract_path_decode() {
        let mut router = Router::<()>::default();
        router.register_resource(Resource::new(ResourceDef::new("/{value}/")));

        let req = TestRequest::with_uri("/%25/").finish();
        let info = router.recognize(&req, &(), 0);
        let req = req.with_route_info(info);
        assert_eq!(*Path::<String>::from_request(&req, &&PathConfig::default()).unwrap(), "%");

        let req = TestRequest::with_uri("/%25/7/?id=test").finish();

        let mut router = Router::<()>::default();
        router.register_resource(Resource::new(ResourceDef::new("/{key}/{value}/")));
        let info = router.recognize(&req, &(), 0);
        let req = req.with_route_info(info);

        let s = Path::<Test2>::from_request(&req, &PathConfig::default()).unwrap();
        assert_eq!(s.key, "%");
        assert_eq!(s.value, 7);

        let s = Path::<(String, String)>::from_request(&req, &PathConfig::default()).unwrap();
        assert_eq!(s.0, "%");
        assert_eq!(s.1, "7");

    }

    #[test]

Review comment (suggestion):
Could you maybe add few test cases from the relevant issue like:
decoding `file%2F%2Fvar%2Flog%2Fsyslog`

Code after:
        let s = Path::<Test2>::from_request(&req, &PathConfig::default()).unwrap();
        assert_eq!(s.as_ref().key, "name");
        assert_eq!(s.value, 32);

        let s = Path::<(String, u8)>::from_request(&req, &PathConfig::default()).unwrap();
        assert_eq!(s.0, "name");
        assert_eq!(s.1, 32);

        let res = Path::<Vec<String>>::extract(&req).unwrap();
        assert_eq!(res[0], "name".to_owned());
        assert_eq!(res[1], "32".to_owned());
    }

    #[test]
    fn test_extract_path_single() {
        let mut router = Router::<()>::default();
        router.register_resource(Resource::new(ResourceDef::new("/{value}/")));

        let req = TestRequest::with_uri("/32/").finish();
        let info = router.recognize(&req, &(), 0);
        let req = req.with_route_info(info);
        assert_eq!(*Path::<i8>::from_request(&req, &&PathConfig::default()).unwrap(), 32);
    }

    #[test]
    fn test_extract_path_decode() {
        let mut router = Router::<()>::default();
        router.register_resource(Resource::new(ResourceDef::new("/{value}/")));

        macro_rules! test_single_value {
            ($value:expr, $expected:expr) => {
                {
                    let req = TestRequest::with_uri($value).finish();
                    let info = router.recognize(&req, &(), 0);
                    let req = req.with_route_info(info);
                    assert_eq!(*Path::<String>::from_request(&req, &PathConfig::default()).unwrap(), $expected);
                }
            }
        }

        test_single_value!("/%25/", "%");
        test_single_value!("/%40%C2%A3%24%25%5E%26%2B%3D/", "@£$%^&+=");
        test_single_value!("/%2B/", "+");
        test_single_value!("/%252B/", "%2B");
        test_single_value!("/%2F/", "/");
        test_single_value!("/%252F/", "%2F");
        test_single_value!("/http%3A%2F%2Flocalhost%3A80%2Ffoo/", "http://localhost:80/foo");
        test_single_value!("/%2Fvar%2Flog%2Fsyslog/", "/var/log/syslog");
        test_single_value!(
            "/http%3A%2F%2Flocalhost%3A80%2Ffile%2F%252Fvar%252Flog%252Fsyslog/",
            "http://localhost:80/file/%2Fvar%2Flog%2Fsyslog"