Function deno_core::specifier_has_uri_scheme

source ·
pub fn specifier_has_uri_scheme(specifier: &str) -> bool
Expand description

Returns true if the input string starts with a sequence of characters that could be a valid URI scheme, like ‘https:’, ‘git+ssh:’ or ‘data:’.

According to RFC 3986 (https://tools.ietf.org/html/rfc3986#section-3.1), a valid scheme has the following format: scheme = ALPHA *( ALPHA / DIGIT / “+” / “-” / “.” )

We additionally require the scheme to be at least 2 characters long, because otherwise a windows path like c:/foo would be treated as a URL, while no schemes with a one-letter name actually exist.