Class: Seo::LinkSanitizer
- Inherits:
-
BaseService
- Object
- BaseService
- Seo::LinkSanitizer
- Defined in:
- app/services/seo/link_sanitizer.rb
Overview
This class takes a single link and sanitize it for the purpose of hosting it
on warmlyyours.com, localized links are delocalized with {locale} (a Liquid variable)
and if relative is specified then the hostname www.warmlyyours.com is ommitted
Defined Under Namespace
Classes: Result
Constant Summary collapse
- WY_HOSTNAME =
'www.warmlyyours.com'- HOSTNAME_IN_PATH =
%r{\A(www\.)?(\w+\.[a-z]{2,3})/?}i
Instance Method Summary collapse
-
#process(href, relative: false) ⇒ Seo::LinkSanitizer::Result
Produces a canonical WarmlyYours URL from an input
href, applying locale, hostname, scheme, and path normalizations so the result is suitable for warmlyyours.com.
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#process(href, relative: false) ⇒ Seo::LinkSanitizer::Result
Produces a canonical WarmlyYours URL from an input href, applying locale, hostname,
scheme, and path normalizations so the result is suitable for warmlyyours.com.
23 24 25 26 27 28 29 30 31 |
# File 'app/services/seo/link_sanitizer.rb', line 23 def process(href, relative: false) href = href.to_s return Result.new(status: :href_missing) if href.blank? return Result.new(status: :not_applicable) if href.start_with?('#') href = href.dup logger.info "Processing #{href}" process_parsed_href(href, relative: relative) end |