Sha256: f8cae00e623a58132b3ebaf6910558b74b8eaa662efba4ee62fd3d25d50a5478

Contents?: true

Size: 397 Bytes

Versions: 40

Compression:

Stored size: 397 Bytes

Contents

# frozen_string_literal: true

require 'set'
module Thredded
  # Excludes pagination routes in addition to the given list of reserved words.
  class FriendlyIdReservedWordsAndPagination
    PAGINATION_PATTERN = /\Apage-\d+\z/i

    def initialize(words = [])
      @words = Set.new(words)
    end

    def include?(slug)
      @words.include?(slug) || slug =~ PAGINATION_PATTERN
    end
  end
end

Version data entries

40 entries across 40 versions & 2 rubygems

Version Path
thredded-1.0.0 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.16 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.15 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.14 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.13 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.12 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.11 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.10 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.9 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.8 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.7 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.6 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.5 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.4 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.3 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.1 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.16.0 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.15.5 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.15.4 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-0.15.3 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb