Sha256: fe693f4ebcf0c727196684ac25261afee44cb0b0c3d431f3c69d5f92ab7393c9
Contents?: true
Size: 762 Bytes
Versions: 32
Compression:
Stored size: 762 Bytes
Contents
# frozen_string_literal: true class WCC::Contentful::Model::Redirect < WCC::Contentful::Model def external_uri @external_uri ||= URI(external_link) if external_link.present? end # A menu link is external if `external_link` is present and not relative. def external? external_uri&.scheme.present? end # Gets either the external link or the slug from the referenced page. # Example usage: `redirect_to redirect.href` def href return external_link if external_link url = (link&.try(:slug) || link&.try(:url)) return url unless fragment.present? url = URI(url || '') url.fragment = fragment url.to_s end def fragment WCC::Contentful::App::SectionHelper.section_id(section_link) if section_link end end
Version data entries
32 entries across 32 versions & 1 rubygems