Lines Matching +full:whatwg +full:- +full:url
1 // Copyright 2013-2016 The rust-url developers.
3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
14 use crate::Url;
18 /// https://url.spec.whatwg.org/#fragment-percent-encode-set
21 /// https://url.spec.whatwg.org/#path-percent-encode-set
24 /// https://url.spec.whatwg.org/#userinfo-percent-encode-set
43 // https://url.spec.whatwg.org/#query-state
64 fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
84 RelativeUrlWithoutBase => "relative URL without a base",
85 RelativeUrlWithCannotBeABaseBase => "relative URL with a cannot-be-a-base base",
86 SetHostOnCannotBeABaseUrl => "a cannot-be-a-base URL doesn’t have a host to set",
91 fn from(_: ::idna::Errors) -> ParseError { in from()
98 /// Non-fatal syntax violations that can occur during parsing.
111 pub fn description(&self) -> &'static str {
128 in an URL is not recommended",
132 NonUrlCodePoint => "non-URL code point",
133 NullInFragment => "NULL characters are ignored in URL fragment identifiers",
140 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { in fmt()
153 pub fn is_special(&self) -> bool { in is_special()
157 pub fn is_file(&self) -> bool { in is_file()
161 pub fn from(s: &str) -> Self { in from()
170 pub fn default_port(scheme: &str) -> Option<u16> { in default_port()
185 pub fn new(input: &'i str) -> Self { in new()
189 pub fn no_trim(input: &'i str) -> Self { in no_trim()
198 ) -> Self { in trim_tab_and_newlines()
213 pub fn with_log(original_input: &'i str, vfn: Option<&dyn Fn(SyntaxViolation)>) -> Self { in with_log()
229 pub fn is_empty(&self) -> bool { in is_empty()
234 fn starts_with<P: Pattern>(&self, p: P) -> bool { in starts_with()
239 pub fn split_prefix<P: Pattern>(&self, p: P) -> Option<Self> { in split_prefix()
249 fn split_first(&self) -> (Option<char>, Self) { in split_first()
255 fn count_matching<F: Fn(char) -> bool>(&self, f: F) -> (u32, Self) { in count_matching()
270 fn next_utf8(&mut self) -> Option<(char, &'i str)> { in next_utf8()
286 fn split_prefix(self, input: &mut Input) -> bool; in split_prefix()
290 fn split_prefix(self, input: &mut Input) -> bool { in split_prefix()
296 fn split_prefix(self, input: &mut Input) -> bool { in split_prefix()
306 impl<F: FnMut(char) -> bool> Pattern for F {
307 fn split_prefix(self, input: &mut Input) -> bool { in split_prefix()
314 fn next(&mut self) -> Option<char> { in next()
323 pub base_url: Option<&'a Url>,
343 fn log_violation_if(&self, v: SyntaxViolation, test: impl FnOnce() -> bool) { in log_violation_if()
351 pub fn for_setter(serialization: String) -> Parser<'a> { in for_setter()
361 /// https://url.spec.whatwg.org/#concept-basic-url-parser
362 pub fn parse_url(mut self, input: &str) -> ParseResult<Url> { in parse_url() argument
368 // No-scheme state in parse_url()
387 pub fn parse_scheme<'i>(&mut self, mut input: Input<'i>) -> Result<Input<'i>, ()> { in parse_scheme()
394 'a'..='z' | 'A'..='Z' | '0'..='9' | '+' | '-' | '.' => { in parse_scheme()
413 fn parse_with_scheme(mut self, input: Input<'_>) -> ParseResult<Url> { in parse_with_scheme() argument
438 // "Cannot-be-a-base" URLs only happen with "not special" schemes. in parse_with_scheme()
464 ) -> ParseResult<Url> { in parse_non_special() argument
469 // Anarchist URL (no authority) in parse_non_special()
500 base_file_url: Option<&Url>, in parse_file() argument
501 ) -> ParseResult<Url> { in parse_file() argument
538 return Ok(Url { in parse_file()
589 return Ok(Url { in parse_file()
612 Ok(Url { in parse_file()
627 Ok(Url { in parse_file()
669 Ok(Url { in parse_file()
692 Ok(Url { in parse_file()
711 base_url: &Url, in parse_relative() argument
712 ) -> ParseResult<Url> { in parse_relative() argument
724 Ok(Url { in parse_relative()
739 Ok(Url { in parse_relative()
795 // A special url always has a path. in parse_relative()
833 ) -> ParseResult<Url> { in after_double_slash() argument
868 ) -> ParseResult<(u32, Input<'i>)> { in parse_userinfo()
893 // url is special and c is U+005C (\) in parse_userinfo()
910 userinfo_char_count -= 1; in parse_userinfo()
943 ) -> ParseResult<(u32, HostInternal, Option<u16>, Input<'i>)> { in parse_host_and_port()
974 ) -> ParseResult<(Host<String>, Input<'_>)> { in parse_host()
1028 fn get_file_host(input: Input<'_>) -> ParseResult<(Host<String>, Input<'_>)> { in get_file_host()
1040 ) -> ParseResult<(bool, HostInternal, Input<'i>)> { in parse_file_host()
1062 pub fn file_host(input: Input) -> ParseResult<(bool, String, Input)> { in file_host()
1100 ) -> ParseResult<(Option<u16>, Input<'_>)> in parse_port()
1102 P: Fn() -> Option<u16>, in parse_port()
1132 ) -> Input<'i> { in parse_path_start()
1135 // If url is special, then: in parse_path_start()
1141 // A special URL always has a non-empty path. in parse_path_start()
1152 // set url’s query to the empty string and state to query state. in parse_path_start()
1154 // set url’s fragment to the empty string and state to fragment state. in parse_path_start()
1172 ) -> Input<'i> { in parse_path()
1219 &self.serialization[segment_start..self.serialization.len() - 1] in parse_path()
1224 // If buffer is a double-dot path segment, shorten url’s path, in parse_path()
1227 debug_assert!(self.serialization.as_bytes()[segment_start - 1] == b'/'); in parse_path()
1236 …/ and then if neither c is U+002F (/), nor url is special and c is U+005C (\), append the empty st… in parse_path()
1241 // Otherwise, if buffer is a single-dot path segment and if neither c is U+002F (/), in parse_path()
1242 // nor url is special and c is U+005C (\), append the empty string to url’s path. in parse_path()
1250 … // If url’s scheme is "file", url’s path is empty, and buffer is a Windows drive letter, then in parse_path()
1261 // If url’s host is neither the empty string nor null, in parse_path()
1262 // validation error, set url’s host to the empty string. in parse_path()
1275 // while url’s path’s size is greater than 1 in parse_path()
1276 // and url’s path[0] is the empty string, in parse_path()
1277 // validation error, remove the first item from url’s path. in parse_path()
1287 fn last_slash_can_be_removed(serialization: &str, path_start: usize) -> bool { in last_slash_can_be_removed()
1288 let url_before_segment = &serialization[..serialization.len() - 1]; in last_slash_can_be_removed()
1299 /// https://url.spec.whatwg.org/#shorten-a-urls-path
1305 …// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, … in shorten_path()
1315 /// https://url.spec.whatwg.org/#pop-a-urls-path
1330 pub fn parse_cannot_be_a_base_path<'i>(&mut self, mut input: Input<'i>) -> Input<'i> { in parse_cannot_be_a_base_path()
1359 ) -> ParseResult<Url> { in with_query_and_fragment() argument
1362 Ok(Url { in with_query_and_fragment()
1382 ) -> ParseResult<(Option<u32>, Option<u32>)> { in parse_query_and_fragment()
1411 ) -> Option<Input<'i>> { in parse_query()
1443 fn fragment_only(mut self, base_url: &Url, mut input: Input<'_>) -> ParseResult<Url> { in fragment_only() argument
1456 Ok(Url { in fragment_only()
1492 fn is_ascii_hex_digit(c: char) -> bool { in is_ascii_hex_digit()
1496 // Non URL code points:
1504 fn is_url_code_point(c: char) -> bool { in is_url_code_point()
1509 '!' | '$' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | '-' | in is_url_code_point()
1522 /// https://url.spec.whatwg.org/#c0-controls-and-space
1524 fn c0_control_or_space(ch: char) -> bool { in c0_control_or_space()
1528 /// https://infra.spec.whatwg.org/#ascii-tab-or-newline
1530 fn ascii_tab_or_new_line(ch: char) -> bool { in ascii_tab_or_new_line()
1534 /// https://url.spec.whatwg.org/#ascii-alpha
1536 pub fn ascii_alpha(ch: char) -> bool { in ascii_alpha()
1541 pub fn to_u32(i: usize) -> ParseResult<u32> { in to_u32()
1549 fn is_normalized_windows_drive_letter(segment: &str) -> bool { in is_normalized_windows_drive_letter()
1556 pub fn is_windows_drive_letter(segment: &str) -> bool { in is_windows_drive_letter()
1562 fn path_starts_with_windows_drive_letter(s: &str) -> bool { in path_starts_with_windows_drive_letter()
1570 fn starts_with_windows_drive_letter(s: &str) -> bool { in starts_with_windows_drive_letter()
1577 /// https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
1578 fn starts_with_windows_drive_letter_segment(input: &Input<'_>) -> bool { in starts_with_windows_drive_letter_segment()