Skip to content

Commit

Permalink
Remove hacky normalize_path (denoland#2660)
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jul 18, 2019
1 parent 55ca0f0 commit a37bc00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
32 changes: 10 additions & 22 deletions cli/deno_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,6 @@ impl SourceFile {
}
}

// TODO(bartlomieju): this should be removed, but integration test 022_info_flag depends on
// using "/" (forward slashes) or doesn't match output on Windows
fn normalize_path(path: &Path) -> PathBuf {
let s = String::from(path.to_str().unwrap());
let normalized_string = if cfg!(windows) {
// TODO This isn't correct. Probbly should iterate over components.
s.replace("\\", "/")
} else {
s
};

PathBuf::from(normalized_string)
}

pub type SourceFileFuture =
dyn Future<Item = SourceFile, Error = ErrBox> + Send;

Expand Down Expand Up @@ -353,11 +339,12 @@ impl DenoDir {
Err(e) => return Err(e.into()),
};

let media_type = map_content_type(&filepath, None);
Ok(SourceFile {
url: module_url.clone(),
redirect_source_url: None,
filename: normalize_path(&filepath),
media_type: map_content_type(&filepath, None),
filename: filepath,
media_type,
source_code,
})
}
Expand Down Expand Up @@ -420,14 +407,15 @@ impl DenoDir {
}
Ok(c) => c,
};
let media_type = map_content_type(
&filepath,
source_code_headers.mime_type.as_ref().map(String::as_str),
);
Ok(Some(SourceFile {
url: module_url.clone(),
redirect_source_url: maybe_initial_module_url,
filename: normalize_path(&filepath),
media_type: map_content_type(
&filepath,
source_code_headers.mime_type.as_ref().map(String::as_str),
),
filename: filepath,
media_type,
source_code,
}))
}
Expand Down Expand Up @@ -512,7 +500,7 @@ impl DenoDir {
let source_file = SourceFile {
url: module_url,
redirect_source_url: maybe_initial_module_url,
filename: normalize_path(&filepath),
filename: filepath,
media_type,
source_code: source.as_bytes().to_owned(),
};
Expand Down
2 changes: 1 addition & 1 deletion tests/022_info_flag.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local: [WILDCARD]deps/http/127.0.0.1_PORT4545/tests/019_media_types.ts
local: [WILDCARD]019_media_types.ts
type: TypeScript
compiled: [WILDCARD].js
map: [WILDCARD].js.map
Expand Down

0 comments on commit a37bc00

Please sign in to comment.