Sha256: cbb997fdd23101a9b4305957085be6b93e77154fcf587535c432f2ec92fb742d

Contents?: true

Size: 402 Bytes

Versions: 2

Compression:

Stored size: 402 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) || PAGINATION_PATTERN.match?(slug)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thredded-1.1.0 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb
thredded-1.0.1 app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb