Skip to content

Commit 38354a7

Browse files
committed
Add more descriptive documentation for Origin
Fixes #310
1 parent 780410c commit 38354a7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/origin.rs

+16
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ pub fn url_origin(url: &Url) -> Origin {
3434
}
3535

3636
/// The origin of an URL
37+
///
38+
/// Two URLs with the same origin are considered
39+
/// to originate from the same entity and can therefore trust
40+
/// each other.
41+
///
42+
/// The origin is determined based on the scheme as follows:
43+
///
44+
/// - If the scheme is "blob" the origin is the origin of the
45+
/// URL contained in the path component. If parsing fails,
46+
/// it is an opaque origin.
47+
/// - If the scheme is "ftp", "gopher", "http", "https", "ws", or "wss",
48+
/// then the origin is a tuple of the scheme, host, and port.
49+
/// - If the scheme is anything else, the origin is opaque, meaning
50+
/// the URL does not have the same origin as any other URL.
51+
///
52+
/// For more information see https://url.spec.whatwg.org/#origin
3753
#[derive(PartialEq, Eq, Clone, Debug)]
3854
pub enum Origin {
3955
/// A globally unique identifier

0 commit comments

Comments
 (0)