Skip to content

Commit 4183d01

Browse files
committed
Remove url path normalization logic
This workaround should no longer be needed for crates.io, and if path normalization is necessary it should be moved into middleware.
1 parent b9b11f3 commit 4183d01

File tree

2 files changed

+0
-43
lines changed

2 files changed

+0
-43
lines changed

src/adaptor.rs

-25
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
1212
use std::io::{Cursor, Read};
1313
use std::net::SocketAddr;
14-
use std::path::{Component, Path, PathBuf};
1514

1615
use conduit::{Extensions, HeaderMap, Host, Method, RequestExt, Scheme, Version};
1716
use http::request::Parts as HttpParts;
@@ -63,30 +62,6 @@ impl ConduitRequest {
6362
pub(crate) fn new(info: &mut RequestInfo, remote_addr: SocketAddr) -> Self {
6463
let (parts, body) = info.take();
6564
let path = parts.0.uri.path().to_string();
66-
let path = Path::new(&path);
67-
let path = path
68-
.components()
69-
// Normalize path (needed by crates.io)
70-
// TODO: Make this optional?
71-
.fold(PathBuf::new(), |mut result, p| match p {
72-
Component::Normal(x) => {
73-
if x != "" {
74-
result.push(x)
75-
};
76-
result
77-
}
78-
Component::ParentDir => {
79-
result.pop();
80-
result
81-
}
82-
Component::RootDir => {
83-
result.push(Component::RootDir);
84-
result
85-
}
86-
_ => result,
87-
})
88-
.to_string_lossy()
89-
.to_string(); // non-Unicode is replaced with U+FFFD REPLACEMENT CHARACTER
9065

9166
Self {
9267
parts,

src/tests.rs

-18
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,6 @@ async fn recover_from_panic() {
125125
assert_generic_err(simulate_request(Panic).await).await;
126126
}
127127

128-
#[tokio::test]
129-
async fn normalize_path() {
130-
let mut service = make_service(AssertPathNormalized);
131-
let req = hyper::Request::put("//removed/.././.././normalized")
132-
.body(hyper::Body::default())
133-
.unwrap();
134-
let resp = service.call(req).await.unwrap();
135-
assert_eq!(resp.status(), StatusCode::OK);
136-
assert_eq!(resp.headers().len(), 1);
137-
138-
let req = hyper::Request::put("//normalized")
139-
.body(hyper::Body::default())
140-
.unwrap();
141-
let resp = service.call(req).await.unwrap();
142-
assert_eq!(resp.status(), StatusCode::OK);
143-
assert_eq!(resp.headers().len(), 1);
144-
}
145-
146128
#[tokio::test]
147129
async fn sleeping_doesnt_block_another_request() {
148130
let mut service = make_service(Sleep);

0 commit comments

Comments
 (0)