Skip to content

Doc origin #344

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

Merged
merged 2 commits into from
May 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,7 @@ impl Url {
/// Change this URL’s scheme.
///
/// Do nothing and return `Err` if:
///
/// * The new scheme is not in `[a-zA-Z][a-zA-Z0-9+.-]+`
/// * This URL is cannot-be-a-base and the new scheme is one of
/// `http`, `https`, `ws`, `wss`, `ftp`, or `gopher`
Expand Down
16 changes: 16 additions & 0 deletions src/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ pub fn url_origin(url: &Url) -> Origin {
}

/// The origin of an URL
///
/// Two URLs with the same origin are considered
/// to originate from the same entity and can therefore trust
/// each other.
///
/// The origin is determined based on the scheme as follows:
///
/// - If the scheme is "blob" the origin is the origin of the
/// URL contained in the path component. If parsing fails,
/// it is an opaque origin.
/// - If the scheme is "ftp", "gopher", "http", "https", "ws", or "wss",
/// then the origin is a tuple of the scheme, host, and port.
/// - If the scheme is anything else, the origin is opaque, meaning
/// the URL does not have the same origin as any other URL.
///
/// For more information see https://url.spec.whatwg.org/#origin
#[derive(PartialEq, Eq, Clone, Debug)]
pub enum Origin {
/// A globally unique identifier
Expand Down