mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
cli: generate default file name for bundle when URL ends in a slash
This commit is contained in:
parent
f4c9b31405
commit
afd66bb010
1 changed files with 5 additions and 1 deletions
|
@ -632,7 +632,7 @@ pub enum DenoSubcommand {
|
||||||
fn get_default_bundle_filename(source_file: &str) -> String {
|
fn get_default_bundle_filename(source_file: &str) -> String {
|
||||||
let specifier = ModuleSpecifier::resolve_url_or_path(source_file).unwrap();
|
let specifier = ModuleSpecifier::resolve_url_or_path(source_file).unwrap();
|
||||||
let path_segments = specifier.as_url().path_segments().unwrap();
|
let path_segments = specifier.as_url().path_segments().unwrap();
|
||||||
let file_name = path_segments.last().unwrap();
|
let file_name = path_segments.filter(|s| !s.is_empty()).last().unwrap();
|
||||||
let file_stem = file_name.trim_end_matches(".ts").trim_end_matches(".js");
|
let file_stem = file_name.trim_end_matches(".ts").trim_end_matches(".js");
|
||||||
format!("{}.bundle.js", file_stem)
|
format!("{}.bundle.js", file_stem)
|
||||||
}
|
}
|
||||||
|
@ -649,6 +649,10 @@ fn test_get_default_bundle_filename() {
|
||||||
get_default_bundle_filename("http://example.com/blah.js"),
|
get_default_bundle_filename("http://example.com/blah.js"),
|
||||||
"blah.bundle.js"
|
"blah.bundle.js"
|
||||||
);
|
);
|
||||||
|
assert_eq!(
|
||||||
|
get_default_bundle_filename("http://zombo.com/stuff/"),
|
||||||
|
"stuff.bundle.js"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flags_from_vec(
|
pub fn flags_from_vec(
|
||||||
|
|
Loading…
Reference in a new issue