class Filters::LocalFilter
Public: Filters
out non-local URIs
Public Instance Methods
filter(index, link, base_uri)
click to toggle source
Public: Filter out resources that are not local.
Returns the link if it should be indexed else nil.
# File lib/sitemap/filters/filters.rb, line 141 def filter(index, link, base_uri) return true unless !should_index_local_link?(link, index, base_uri) false end
is_link_local?(link, local)
click to toggle source
Public: Determines if a link is on the local domain + path or not
# File lib/sitemap/filters/filters.rb, line 101 def is_link_local?(link, local) begin link = Filters::Util.make_URI(link) local = Filters::Util.make_URI(local) # Remove Absolute URLs that don't refer to local domain if !link.host.nil? && !link.host.eql?(local.host) log.debug("Rejecting host #{link.host} as it doesn't match #{local.host}") return false end # Ensure path starts with a '/' (filters out junk URLs) if !link.path.nil? && !link.path.eql?('') && !link.path.start_with?('/') log.debug("Rejecting link #{link} as it's path (#{link.path}) doesn't start with '/'") return false end rescue StandardError => bang log.debug("Exception looking for local links: " + bang.message) return false end return true end
should_index_local_link?(link, index, base_uri)
click to toggle source
Public: Determines if a link should be indexed.
Returns boolean true iff the link is local and not indexed.
# File lib/sitemap/filters/filters.rb, line 132 def should_index_local_link?(link, index, base_uri) return !index.has_key?(link.to_s) && is_link_local?(link, base_uri) end