pub enum ReferrerPolicy {
NoReferrer,
NoReferrerWhenDowngrade,
Origin,
OriginWhenCrossOrigin,
SameOrigin,
StrictOrigin,
StrictOriginWhenCrossOrigin,
UnsafeUrl,
}Expand description
The referrerpolicy attribute values.
§Purpose
Controls how much referrer information is sent with requests, enabling privacy control over what information is shared with linked resources.
§Usage Context
- Used with:
<a>,<area>,<img>,<iframe>,<link>,<script>elements - Privacy: Determines what URL information is sent in the Referer header
- Security: Prevents leaking sensitive URLs to third parties
§Valid Values
NoReferrer: Never send referrer informationNoReferrerWhenDowngrade: Send referrer only on same security levelOrigin: Send only the origin (scheme, host, port)OriginWhenCrossOrigin: Send full URL for same-origin, origin for cross-originSameOrigin: Send referrer only for same-origin requestsStrictOrigin: Send origin, but not when downgrading HTTPS→HTTPStrictOriginWhenCrossOrigin: Full URL same-origin, origin cross-origin, none on downgradeUnsafeUrl: Always send the full URL (not recommended)
§Example
use ironhtml_attributes::{AttributeValue, ReferrerPolicy};
let policy = ReferrerPolicy::NoReferrer;
assert_eq!(policy.to_attr_value(), "no-referrer");<a href="https://example.com" referrerpolicy="no-referrer">Private Link</a>
<img src="https://example.com/img.jpg" referrerpolicy="origin">
<iframe src="https://example.com" referrerpolicy="strict-origin-when-cross-origin"></iframe>§WHATWG Specification
Variants§
NoReferrer
Never send referrer information. Maximum privacy.
NoReferrerWhenDowngrade
Send referrer only when not downgrading from HTTPS to HTTP. This is often the browser default.
Origin
Send only the origin (no path or query string).
OriginWhenCrossOrigin
Send full URL for same-origin requests, only origin for cross-origin.
SameOrigin
Send referrer only for same-origin requests, nothing for cross-origin.
StrictOrigin
Send only origin, and not when downgrading from HTTPS to HTTP.
StrictOriginWhenCrossOrigin
Send full URL for same-origin, origin for cross-origin, nothing when downgrading. Recommended for most use cases.
UnsafeUrl
Always send the full URL as referrer. Not recommended due to privacy and security concerns.
Trait Implementations§
Source§impl AttributeValue for ReferrerPolicy
impl AttributeValue for ReferrerPolicy
Source§fn to_attr_value(&self) -> Cow<'static, str>
fn to_attr_value(&self) -> Cow<'static, str>
Source§impl Clone for ReferrerPolicy
impl Clone for ReferrerPolicy
Source§fn clone(&self) -> ReferrerPolicy
fn clone(&self) -> ReferrerPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more