diff --git a/src/lib.rs b/src/lib.rs index ab6b9fd..88ecfee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,16 +85,16 @@ mod macros; /// syntactically correct ranges actually makes sense in context /// /// The range `bytes=0-20` on a file with 15 bytes will be accepted in the first pass as the content_size is unknown. -/// On the second pass (`validate`) it will be rejected and produce an error -/// # Example range fails `validate` because it exceedes file boundaries +/// On the second pass (`validate`) it will be truncated to `file_size - 1` as per [the spec](https://httpwg.org/specs/rfc9110.html#rfc.section.14.1.2). +/// # Example range truncates in `validate` because it exceedes /// ``` /// let input = "bytes=0-20"; /// let file_size_bytes = 15; /// let parsed_ranges = http_range_header::parse_range_header(input) /// // Is syntactically correct /// .unwrap(); -/// let validated = parsed_ranges.validate(file_size_bytes); -/// assert!(validated.is_err()); +/// let validated = parsed_ranges.validate(file_size_bytes).unwrap(); +/// assert_eq!(vec![0..=14], validated); /// ``` /// /// Range reversal and overlap is also checked in the second pass, the range `bytes=0-20, 5-10`