<commit_before>module Trinidad
  class WebApp
    attr_reader :context, :config
  
    def self.create(context, config)
      config.has_key?(:rackup) ? RackupWebApp.new(context, config) : RailsWebApp.new(context, config) 
    end
    
    def initialize(context, config)
      @context = context
      @config = config
    end
    
    def add_rack_filter
      unless rack_filter_configured?
        filter_def = Trinidad::Tomcat::FilterDef.new
        filter_def.setFilterName('RackFilter')
        filter_def.setFilterClass('org.jruby.rack.RackFilter')

        pattern = @config[:context_path][-1..-1] != '/' ? @config[:context_path] : @config[:context_path][0..-2]
        filter_map = Trinidad::Tomcat::FilterMap.new
        filter_map.setFilterName('RackFilter')
        filter_map.addURLPattern("#{pattern}/*")

        @context.addFilterDef(filter_def)
        @context.addFilterMap(filter_map)
      end
    end<commit_msg>removing pattern to allow different context paths<commit_after>module Trinidad
  class WebApp
    attr_reader :context, :config
  
    def self.create(context, config)
      config.has_key?(:rackup) ? RackupWebApp.new(context, config) : RailsWebApp.new(context, config) 
    end
    
    def initialize(context, config)
      @context = context
      @config = config
    end
    
    def add_rack_filter
      unless rack_filter_configured?
        filter_def = Trinidad::Tomcat::FilterDef.new
        filter_def.setFilterName('RackFilter')
        filter_def.setFilterClass('org.jruby.rack.RackFilter')

        filter_map = Trinidad::Tomcat::FilterMap.new
        filter_map.setFilterName('RackFilter')
        filter_map.addURLPattern('/*')

        @context.addFilterDef(filter_def)
        @context.addFilterMap(filter_map)
      end
    end
{'fraction_non_alphanumeric': 0.10668163952835485, 'fraction_numerical': 0.0022459292532285235, 'mean_word_length': 3.1059907834101383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2191050', 'n_tokens_mistral': 572, 'n_tokens_neox': 549, 'n_words': 89}