Skip to content

Commit

Permalink
Check that regexps match in linear time (#3042)
Browse files Browse the repository at this point in the history
  • Loading branch information
lloeki authored Jan 17, 2025
1 parent 41dc832 commit 3e81a5a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/datadog/tracing/contrib/utils/quantization/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
require 'datadog/tracing/contrib/utils/quantization/http'

RSpec.describe Datadog::Tracing::Contrib::Utils::Quantization::HTTP do
describe 'RFC3986_URL_BASE' do
let(:regex) { described_class::RFC3986_URL_BASE }

it 'matches in linear time' do
if !Regexp.respond_to?(:linear_time?)
skip 'Regexp.linear_time? method is only available on Ruby 3.3+'
else
pending
expect(Regexp.linear_time?(regex)).to be true
end
end
end

describe '#url' do
subject(:result) { described_class.url(url, options) }

Expand Down Expand Up @@ -569,6 +582,14 @@
}
# rubocop:enable Layout/LineLength

it 'matches in linear time' do
if !Regexp.respond_to?(:linear_time?)
skip 'Regexp.linear_time? method is only available on Ruby 3.3+'
else
expect(Regexp.linear_time?(regex)).to be true
end
end

key_matches.each do |key|
context "given query string key #{key.inspect} and its value" do
let(:str) { format('%<key>s=foo', { key: key }) }
Expand Down

0 comments on commit 3e81a5a

Please sign in to comment.