Sha256: 387e273c63b7fc71f1904eb8318398aafc401970efd4bb54f6233a024a1b94d6

Contents?: true

Size: 586 Bytes

Versions: 15

Compression:

Stored size: 586 Bytes

Contents

# frozen_string_literal: true

require 'uri'

module Maglev
  class PreviewConstraint
    attr_reader :preview_host

    def initialize(preview_host: nil)
      @preview_host = preview_host == true ? default_preview_host : preview_host
    end

    def matches?(request)
      %i[html xml].include?(request.format.symbol) && (!preview_host || preview_host == request.host)
    end

    protected

    def default_preview_host
      return nil if Maglev.config.preview_host.blank?

      URI.parse(Maglev.config.preview_host).host # make sure we get only the host here
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
maglevcms-1.2.2 lib/maglev/preview_constraint.rb
maglevcms-1.2.1 lib/maglev/preview_constraint.rb
maglevcms-1.2.0 lib/maglev/preview_constraint.rb
maglevcms-1.1.7 lib/maglev/preview_constraint.rb
maglevcms-1.1.6 lib/maglev/preview_constraint.rb
maglevcms-1.1.5 lib/maglev/preview_constraint.rb
maglevcms-1.1.4 lib/maglev/preview_constraint.rb
maglevcms-1.1.3 lib/maglev/preview_constraint.rb
maglevcms-1.1.2 lib/maglev/preview_constraint.rb
maglevcms-1.1.1 lib/maglev/preview_constraint.rb
maglevcms-1.1.0 lib/maglev/preview_constraint.rb
maglevcms-1.0.0 lib/maglev/preview_constraint.rb
maglevcms-1.0.0.rc3 lib/maglev/preview_constraint.rb
maglevcms-1.0.0.rc2 lib/maglev/preview_constraint.rb
maglevcms-1.0.0.rc1 lib/maglev/preview_constraint.rb