mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Added some same-origin-domain checks.
This commit is contained in:
parent
628cd7de6d
commit
1f61a549a3
45 changed files with 223 additions and 348 deletions
|
@ -15,7 +15,7 @@
|
|||
//! those cases are not present.
|
||||
|
||||
use servo_config::resource_files::read_resource_file;
|
||||
use servo_url::ServoUrl;
|
||||
use servo_url::{Host, ImmutableOrigin, ServoUrl};
|
||||
use std::collections::HashSet;
|
||||
use std::iter::FromIterator;
|
||||
use std::str::from_utf8;
|
||||
|
@ -146,6 +146,11 @@ pub fn is_reg_domain(domain: &str) -> bool {
|
|||
/// Returns None if the URL has no host name.
|
||||
/// Returns the registered suffix for the host name if it is a domain.
|
||||
/// Leaves the host name alone if it is an IP address.
|
||||
pub fn reg_host<'a>(url: &'a ServoUrl) -> Option<&'a str> {
|
||||
url.domain().map(reg_suffix).or(url.host_str())
|
||||
pub fn reg_host<'a>(url: &'a ServoUrl) -> Option<Host> {
|
||||
match url.origin() {
|
||||
ImmutableOrigin::Tuple(_, Host::Domain(domain), _) => Some(Host::Domain(String::from(reg_suffix(&*domain)))),
|
||||
ImmutableOrigin::Tuple(_, Host::Ipv4(address), _) => Some(Host::Ipv4(address)),
|
||||
ImmutableOrigin::Tuple(_, Host::Ipv6(address), _) => Some(Host::Ipv6(address)),
|
||||
ImmutableOrigin::Opaque(_) => None,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue