Sha256: fbf24c6b78d5cea4a9cffc647709c2d4f2184e4e6221fb0f24953b29013bf4d2

Contents?: true

Size: 588 Bytes

Versions: 17

Compression:

Stored size: 588 Bytes

Contents

# frozen_string_literal: true

require 'rack'

module OpenTracing
  module Instrumentation
    module Rack
      # RegexpHostSanitazer sanitaze host
      class RegexpHostSanitazer
        DEFAULT_REPLACE_MAP = {
          '\1.0.0.0' => /^(\d+)\.\d+\.\d+\.\d+:\d+$/,
        }.freeze

        def initialize(replace_map: DEFAULT_REPLACE_MAP)
          @replace_map = replace_map
        end

        def sanitaze_host(host)
          @replace_map.each do |pattern, regexp|
            host = host.gsub(regexp, pattern)
          end
          host
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
opentracing-instrumentation-0.2.1 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.2.0 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.18 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.17 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.16 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.15 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.14 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.13 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.12 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.11 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.10 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.9 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.8 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.7 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.6 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.5 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
opentracing-instrumentation-0.1.4 lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb