Skip to content
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

bug: ModuleSpecifier parsing on Windows #3355

Closed
bartlomieju opened this issue Nov 15, 2019 · 4 comments
Closed

bug: ModuleSpecifier parsing on Windows #3355

bartlomieju opened this issue Nov 15, 2019 · 4 comments
Labels

Comments

@bartlomieju
Copy link
Member

It seems there are still problems with ModuleSpecifier parsing on Windows.

In #3344 I encountered problem on Windows CI where this path:

c:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\.tmpGMWvcR\\.deno.test.ts

was parsed as module specifier having c: scheme instead of file:// and I had to manually add file:// prefix doing dynamic import.

@axetroy
Copy link
Contributor

axetroy commented Nov 15, 2019

Finally. I got this problem in #3346.

I am curious why CI failed under Windows.

I spent a lot of time exploring the problem.

@piscisaureus
Copy link
Member

@bartlomieju

There is already logic to deal with this case:

fn specifier_has_uri_scheme(specifier: &str) -> bool {
let mut chars = specifier.chars();
let mut len = 0usize;
// THe first character must be a letter.
match chars.next() {
Some(c) if c.is_ascii_alphabetic() => len += 1,
_ => return false,
}
// Second and following characters must be either a letter, number,
// plus sign, minus sign, or dot.
loop {
match chars.next() {
Some(c) if c.is_ascii_alphanumeric() || "+-.".contains(c) => len += 1,
Some(':') if len >= 2 => return true,
_ => return false,
}
}
}
}

Can you figure out why it is not working?

@piscisaureus piscisaureus removed their assignment Apr 6, 2020
@bartossh
Copy link
Contributor

If something goes wrong it is here #L143. Url::from_file_path()) used here #L157 will panic if invalid path is passed. If this statement #L143 is not working as expected, We would be facing panic from this function: L129: Url::parse().

I am not able to fix it reliably, as I don't have access to Windows running machine. On Unix/Linux OS path encoding works fine.

What do you think ?

@stale
Copy link

stale bot commented Jan 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 6, 2021
@stale stale bot closed this as completed Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants