lib/panchira/resolvers/resolver.rb
# URL pattern that a resolver tries to resolve.
# You must override this in subclasses to limit which urls to resolve.
URL pattern that a resolver tries to resolve.
You must override this in subclasses to limit which urls to resolve.
URL pattern that a resolver tries to resolve . You must override this in subclasses to limit which urls to resolve .
def parse_canonical_url
        history = []
        loop do
          url_in_res = @page.css('//link[rel="canonical"]/@href').to_s
          if url_in_res.empty?
            url_in_res = @page.css('//meta[property="og:url"]/@content').to_s
          end
          if url_in_res.empty?
            return history.last || @url
          end
          if history.include?(url_in_res) || history.length > 5
            return url_in_res
          end
          history.push(url_in_res)
          @page = fetch_page(url_in_res)
        end
      end
def parse_canonical_url history = [ ] loop do url_in_res = @page . css ( '//link[rel="canonical"]/@href' ) . to_s if url_in_res . empty? url_in_res = @page . css ( '//meta[property="og:url"]/@content' ) . to_s end if url_in_res . empty? return history . last || @url end if history . include? ( url_in_res ) || history . length > 5 return url_in_res end history . push ( url_in_res ) @page = fetch_page ( url_in_res ) end end
URL pattern that a resolver tries to resolve.
URL pattern that a resolver tries to resolve .
# fetch page and refresh canonical_url until canonical_url converges.