Skip to content

Commit 0dfc893

Browse files
author
bors-servo
authored
Auto merge of #344 - tmccombs:doc-origin, r=SimonSapin
Doc origin <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/344) <!-- Reviewable:end -->
2 parents e461e34 + 4383933 commit 0dfc893

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,7 @@ impl Url {
13681368
/// Change this URL’s scheme.
13691369
///
13701370
/// Do nothing and return `Err` if:
1371+
///
13711372
/// * The new scheme is not in `[a-zA-Z][a-zA-Z0-9+.-]+`
13721373
/// * This URL is cannot-be-a-base and the new scheme is one of
13731374
/// `http`, `https`, `ws`, `wss`, `ftp`, or `gopher`

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)