diff options
Diffstat (limited to 'cli/file_fetcher.rs')
-rw-r--r-- | cli/file_fetcher.rs | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 3d9ae8000..0e01237d9 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -59,7 +59,7 @@ pub struct File { /// The resolved media type for the file. pub media_type: MediaType, /// The source of the file as a string. - pub source: Arc<String>, + pub source: Arc<str>, /// The _final_ specifier for the file. The requested specifier and the final /// specifier maybe different for remote files that have been redirected. pub specifier: ModuleSpecifier, @@ -161,7 +161,7 @@ fn fetch_local(specifier: &ModuleSpecifier) -> Result<File, AnyError> { local, maybe_types: None, media_type, - source: Arc::new(source), + source: source.into(), specifier: specifier.clone(), maybe_headers: None, }) @@ -383,7 +383,7 @@ impl FileFetcher { local, maybe_types, media_type, - source: Arc::new(source), + source: source.into(), specifier: specifier.clone(), maybe_headers: Some(headers.clone()), }) @@ -469,7 +469,7 @@ impl FileFetcher { local, maybe_types: None, media_type, - source: Arc::new(source), + source: source.into(), specifier: specifier.clone(), maybe_headers: Some(headers), }) @@ -533,7 +533,7 @@ impl FileFetcher { local, maybe_types: None, media_type, - source: Arc::new(source), + source: source.into(), specifier: specifier.clone(), maybe_headers: Some(headers), }) @@ -815,7 +815,7 @@ mod tests { let url_str = format!("http://127.0.0.1:4545/encoding/{}", fixture); let specifier = resolve_url(&url_str).unwrap(); let (file, headers) = test_fetch_remote(&specifier).await; - assert_eq!(file.source.as_str(), expected); + assert_eq!(&*file.source, expected); assert_eq!(file.media_type, MediaType::TypeScript); assert_eq!( headers.get("content-type").unwrap(), @@ -827,7 +827,7 @@ mod tests { let p = test_util::testdata_path().join(format!("encoding/{}.ts", charset)); let specifier = resolve_url_or_path(p.to_str().unwrap()).unwrap(); let (file, _) = test_fetch(&specifier).await; - assert_eq!(file.source.as_str(), expected); + assert_eq!(&*file.source, expected); } #[test] @@ -1037,7 +1037,7 @@ mod tests { local, maybe_types: None, media_type: MediaType::TypeScript, - source: Arc::new("some source code".to_string()), + source: "some source code".into(), specifier: specifier.clone(), maybe_headers: None, }; @@ -1067,7 +1067,7 @@ mod tests { let maybe_file = file_fetcher.get_source(&specifier); assert!(maybe_file.is_some()); let file = maybe_file.unwrap(); - assert_eq!(file.source.as_str(), "export const redirect = 1;\n"); + assert_eq!(&*file.source, "export const redirect = 1;\n"); assert_eq!( file.specifier, resolve_url("http://localhost:4545/subdir/redirects/redirect1.js") @@ -1094,7 +1094,7 @@ mod tests { assert!(result.is_ok()); let file = result.unwrap(); assert_eq!( - file.source.as_str(), + &*file.source, "export const a = \"a\";\n\nexport enum A {\n A,\n B,\n C,\n}\n" ); assert_eq!(file.media_type, MediaType::TypeScript); @@ -1126,7 +1126,7 @@ mod tests { assert!(result.is_ok()); let file = result.unwrap(); assert_eq!( - file.source.as_str(), + &*file.source, "export const a = \"a\";\n\nexport enum A {\n A,\n B,\n C,\n}\n" ); assert_eq!(file.media_type, MediaType::TypeScript); @@ -1149,7 +1149,7 @@ mod tests { assert!(result.is_ok()); let file = result.unwrap(); assert_eq!( - file.source.as_str(), + &*file.source, "export { printHello } from \"./print_hello.ts\";\n" ); assert_eq!(file.media_type, MediaType::TypeScript); @@ -1172,7 +1172,7 @@ mod tests { assert!(result.is_ok()); let file = result.unwrap(); assert_eq!( - file.source.as_str(), + &*file.source, "export { printHello } from \"./print_hello.ts\";\n" ); // This validates that when using the cached value, because we modified @@ -1193,7 +1193,7 @@ mod tests { assert!(result.is_ok()); let file = result.unwrap(); assert_eq!( - file.source.as_str(), + &*file.source, "export { printHello } from \"./print_hello.ts\";\n" ); assert_eq!(file.media_type, MediaType::Json); @@ -1216,7 +1216,7 @@ mod tests { assert!(result.is_ok()); let file = result.unwrap(); assert_eq!( - file.source.as_str(), + &*file.source, "export { printHello } from \"./print_hello.ts\";\n" ); assert_eq!(file.media_type, MediaType::TypeScript); @@ -1602,7 +1602,7 @@ mod tests { .await; assert!(result.is_ok()); let file = result.unwrap(); - assert_eq!(file.source.as_str(), r#"console.log("hello deno");"#); + assert_eq!(&*file.source, r#"console.log("hello deno");"#); fs::write(fixture_path, r#"console.log("goodbye deno");"#).unwrap(); let result = file_fetcher @@ -1610,7 +1610,7 @@ mod tests { .await; assert!(result.is_ok()); let file = result.unwrap(); - assert_eq!(file.source.as_str(), r#"console.log("goodbye deno");"#); + assert_eq!(&*file.source, r#"console.log("goodbye deno");"#); } #[tokio::test] @@ -1626,7 +1626,7 @@ mod tests { .await; assert!(result.is_ok()); let file = result.unwrap(); - let first = file.source.as_str(); + let first = file.source; let (file_fetcher, _) = setup(CacheSetting::RespectHeaders, Some(temp_dir.clone())); @@ -1635,7 +1635,7 @@ mod tests { .await; assert!(result.is_ok()); let file = result.unwrap(); - let second = file.source.as_str(); + let second = file.source; assert_ne!(first, second); } @@ -1653,7 +1653,7 @@ mod tests { .await; assert!(result.is_ok()); let file = result.unwrap(); - let first = file.source.as_str(); + let first = file.source; let (file_fetcher, _) = setup(CacheSetting::RespectHeaders, Some(temp_dir.clone())); @@ -1662,7 +1662,7 @@ mod tests { .await; assert!(result.is_ok()); let file = result.unwrap(); - let second = file.source.as_str(); + let second = file.source; assert_eq!(first, second); } |