0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

core: replace ModuleSpecifier::to_url() by as_url()

This commit is contained in:
Bert Belder 2019-07-08 23:04:07 +02:00
parent 72d9045528
commit f4c9b31405
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461
4 changed files with 11 additions and 13 deletions

View file

@ -199,8 +199,8 @@ impl DenoDir {
use_cache: bool,
no_fetch: bool,
) -> impl Future<Item = ModuleMetaData, Error = deno_error::DenoError> {
let module_url = specifier.to_url();
debug!("fetch_module_meta_data. specifier {} ", module_url);
let module_url = specifier.as_url().to_owned();
debug!("fetch_module_meta_data. specifier {} ", &module_url);
let result = self.url_to_deps_path(&module_url);
if let Err(err) = result {

View file

@ -6,6 +6,7 @@ use clap::ArgMatches;
use clap::Shell;
use clap::SubCommand;
use crate::deno_dir;
use deno::ModuleSpecifier;
use log::Level;
use std;
use std::str;
@ -629,14 +630,11 @@ pub enum DenoSubcommand {
}
fn get_default_bundle_filename(source_file: &str) -> String {
use deno::ModuleSpecifier;
let url = ModuleSpecifier::resolve_url_or_path(source_file)
.unwrap()
.to_url();
let path_segments = url.path_segments().unwrap();
let last = path_segments.last().unwrap();
String::from(last.trim_end_matches(".ts").trim_end_matches(".js"))
+ ".bundle.js"
let specifier = ModuleSpecifier::resolve_url_or_path(source_file).unwrap();
let path_segments = specifier.as_url().path_segments().unwrap();
let file_name = path_segments.last().unwrap();
let file_stem = file_name.trim_end_matches(".ts").trim_end_matches(".js");
format!("{}.bundle.js", file_stem)
}
#[test]

View file

@ -384,7 +384,7 @@ impl ImportMap {
let address = address_vec.first().unwrap();
let after_prefix = &normalized_specifier[specifier_key.len()..];
let base_url = address.to_url();
let base_url = address.as_url();
if let Ok(url) = base_url.join(after_prefix) {
debug!("Specifier {:?} was mapped to {:?} (via prefix specifier key {:?}).", normalized_specifier, url, address);
return Ok(Some(ModuleSpecifier::from(url)));

View file

@ -43,8 +43,8 @@ impl fmt::Display for ModuleResolutionError {
pub struct ModuleSpecifier(Url);
impl ModuleSpecifier {
pub fn to_url(&self) -> Url {
self.0.clone()
pub fn as_url(&self) -> &Url {
&self.0
}
/// Resolves module using this algorithm: