-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Guess extensions on extension not provided #859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
c6a2413
bffb412
699822b
09739fb
469771e
c4f5adb
02fbf23
9da5589
b9d1ccc
eb95e04
c211eb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,13 +3,14 @@ | |
| use errors::DenoResult; | ||
| use tokio_util; | ||
|
|
||
| use futures::Future; | ||
| // use futures::Future; | ||
| use futures::Stream; | ||
| use hyper; | ||
| use hyper::client::Client; | ||
|
kevinkassimo marked this conversation as resolved.
|
||
| use hyper::client::HttpConnector; | ||
| use hyper::Uri; | ||
| use hyper_rustls; | ||
| use std::io; | ||
|
|
||
| type Connector = hyper_rustls::HttpsConnector<HttpConnector>; | ||
|
|
||
|
|
@@ -31,10 +32,15 @@ pub fn get_client() -> Client<Connector, hyper::Body> { | |
| pub fn fetch_sync_string(module_name: &str) -> DenoResult<String> { | ||
| let url = module_name.parse::<Uri>().unwrap(); | ||
| let client = get_client(); | ||
| let future = client | ||
| .get(url) | ||
| .and_then(|response| response.into_body().concat2()); | ||
| let body = tokio_util::block_on(future)?; | ||
| let get_future = client.get(url); | ||
| let response = tokio_util::block_on(get_future)?; | ||
| if !response.status().is_success() { | ||
| Err(io::Error::new( | ||
| io::ErrorKind::NotFound, | ||
| format!("cannot load from '{}'", module_name), | ||
| ))?; | ||
| } | ||
| let body = tokio_util::block_on(response.into_body().concat2())?; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it doesn't matter but this could be done using only one
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I have somehow combined into a single btw a NotFound test is added |
||
| Ok(String::from_utf8(body.to_vec()).unwrap()) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Downloading http://localhost:4545/tests/subdir/mod2.ts | ||
| Downloading http://localhost:4545/tests/subdir/print_hello.ts | ||
| true | ||
| [Function: printHello] | ||
| [Function: printHello] | ||
| true | ||
| [Function: printHello] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { isTSFile, printHello, phNoExt } from "./subdir/mod3"; | ||
| console.log(isTSFile); | ||
| console.log(printHello); | ||
| console.log(phNoExt); | ||
|
|
||
| import { isMod4 } from "./subdir/mod4"; | ||
| console.log(isMod4); | ||
|
|
||
| import { printHello as ph } from "http://localhost:4545/tests/subdir/mod2"; | ||
| console.log(ph); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const isTSFile = false; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export const isTSFile = true; | ||
| export { printHello } from "./print_hello.ts"; | ||
| export { printHello as phNoExt } from "./print_hello"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const isMod4 = true; |
Uh oh!
There was an error while loading. Please reload this page.