Sha256: 941fb652cd446d88b7c4bd4442bdc581d45a2b77bb89400678379589aff19f87

Contents?: true

Size: 697 Bytes

Versions: 17

Compression:

Stored size: 697 Bytes

Contents

# frozen_string_literal: true

require 'rack'

module OpenTracing
  module Instrumentation
    module Rack
      # RegexpPathSanitazer return raw path
      class RegexpPathSanitazer
        DEFAULT_REPLACE_MAP = {
          '/:object_id\1' => %r{/[0-9a-f]{24}(/|$)},
          '/:sequence_id\1' => %r{/\d+(/|$)},
          '/:phone\1' => %r{/\+\d+(/|$)},
        }.freeze

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

        def sanitaze_path(path)
          @replace_map.each do |(target, regexp)|
            path = path.gsub(regexp, target)
          end
          path
        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_path_sanitazer.rb
opentracing-instrumentation-0.2.0 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.18 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.17 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.16 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.15 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.14 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.13 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.12 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.11 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.10 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.9 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.8 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.7 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.6 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.5 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.4 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb