Skip to main content

validate_link_field

Function validate_link_field 

Source
pub fn validate_link_field(value: &str) -> Result<()>
Expand description

Validates a value used as an item-level link field.

Per RSS 2.0 §5.7 item-level link URLs may be relative. This helper accepts:

  • absolute URLs (any scheme that url::Url parses), e.g. https://example.com/post
  • root-relative paths starting with /, e.g. /tags/
  • bare paths without a leading slash, e.g. articles/foo.html

Rejects:

  • the empty string (caller should check is_empty() first)
  • any string containing whitespace or ASCII control characters — those would round-trip into the rendered RSS XML and break well-formedness or feed-reader parsing.

§Errors

Returns RssError::InvalidUrl with a descriptive message when the input contains whitespace or control characters, or is empty.