module

Vug::UrlProcessor

Constants

FEED_PATH_PATTERN = /\ \/( (atom|rss|feed|index)\.(xml|rss|rdf) | feeds?(\/|\z) | (rss|atom|feed)(\/|\z) )\z /ix

Matches common feed URL path suffixes

FEED_SUBDOMAIN_PATTERN = /\Afeeds?\./i

Matches feed-like subdomains (e.g., feeds.example.com, feed.example.com)

Class methods

derive_site_url(url : String) : String

Derives the site root URL from a feed URL. For feed subdomains (e.g., feeds.example.com), strips the subdomain and returns the parent domain origin. For feed paths (e.g., example.com/atom.xml), strips the path and returns the origin. For non-feed URLs, returns the URL unchanged.

Source
extract_host_from_url(url : String) : String | Nil

Extracts host from URL, handling feed URLs and HTTP/HTTPS schemes Sanitizes by removing /feed/ suffix and extracts hostname from URI

Source
feed_subdomain?(url : String) : Bool

Returns true if the URL's host starts with a feed-like subdomain (e.g., feeds.example.com or feed.example.com).

Source
feed_url?(url : String) : Bool

Returns true if the URL path looks like a feed endpoint

Source
normalize_url(url : String, base_scheme : String = "https") : String

Normalizes protocol-relative URLs (//example.com) to absolute URLs

Source
parse_and_validate(url : String) : URI | Nil

Parse and validate a URL in one step: sanitize feed suffixes, validate scheme and host safety, and return a parsed URI. Returns nil if the URL is invalid, dangerous, or unparseable.

Source
resolve_and_normalize(href : String, base : String, base_scheme : String = "https") : String

Resolves relative URLs and normalizes protocol-relative URLs in one step. If href is already absolute, it is normalized. If relative, it is resolved against base first, then normalized.

Source
resolve_url(url : String, base : String) : String

Resolves relative URLs against a base URL

Source
sanitize_and_derive_site_url(url : String) : String

Convenience: sanitize a feed URL and derive the site root URL in one step.

Source
sanitize_feed_url(url : String) : String

Sanitizes URL by removing /feed/ suffix

Source
valid_scheme?(url : String) : Bool

Validates that a URL has a safe scheme (http/https only)

Source