diff options
author | Bert Belder <bertbelder@gmail.com> | 2019-07-08 09:55:24 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2019-07-08 13:07:32 +0200 |
commit | 9b1997b8b6f82e17e42c43aae3621e2b932f5843 (patch) | |
tree | 3367eadf1cdbd7d1f6f3e1ba647d80d85a6d3caa /cli/state.rs | |
parent | 92ac616708cb067a1b895283913c5ecd25c6d873 (diff) |
core: clearly define when module lookup is path-based vs URL-based
The rules are now as follows:
* In `import` statements, as mandated by the WHATWG specification,
the import specifier is always treated as a URL.
If it is a relative URL, it must start with either / or ./ or ../
* A script name passed to deno as a command line argument may be either
an absolute URL or a local path.
- If the name starts with a valid URI scheme followed by a colon, e.g.
'http:', 'https:', 'file:', 'foo+bar:', it always interpreted as a
URL (even if Deno doesn't support the indicated protocol).
- Otherwise, the script name is interpreted as a local path. The local
path may be relative, and operating system semantics determine how
it is resolved. Prefixing a relative path with ./ is not required.
Diffstat (limited to 'cli/state.rs')
-rw-r--r-- | cli/state.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cli/state.rs b/cli/state.rs index fd209a0f2..056226511 100644 --- a/cli/state.rs +++ b/cli/state.rs @@ -170,7 +170,8 @@ impl Loader for ThreadSafeState { } } - ModuleSpecifier::resolve(specifier, referrer).map_err(DenoError::from) + ModuleSpecifier::resolve_import(specifier, referrer) + .map_err(DenoError::from) } /// Given an absolute url, load its source code. @@ -252,7 +253,7 @@ impl ThreadSafeState { None } else { let root_specifier = argv_rest[1].clone(); - match ModuleSpecifier::resolve_root(&root_specifier) { + match ModuleSpecifier::resolve_url_or_path(&root_specifier) { Ok(specifier) => Some(specifier), Err(e) => { // TODO: handle unresolvable specifier |