Skip to content

Commit 3e81a5a

Browse files
authored
Check that regexps match in linear time (#3042)
1 parent 41dc832 commit 3e81a5a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: spec/datadog/tracing/contrib/utils/quantization/http_spec.rb

+21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
require 'datadog/tracing/contrib/utils/quantization/http'
44

55
RSpec.describe Datadog::Tracing::Contrib::Utils::Quantization::HTTP do
6+
describe 'RFC3986_URL_BASE' do
7+
let(:regex) { described_class::RFC3986_URL_BASE }
8+
9+
it 'matches in linear time' do
10+
if !Regexp.respond_to?(:linear_time?)
11+
skip 'Regexp.linear_time? method is only available on Ruby 3.3+'
12+
else
13+
pending
14+
expect(Regexp.linear_time?(regex)).to be true
15+
end
16+
end
17+
end
18+
619
describe '#url' do
720
subject(:result) { described_class.url(url, options) }
821

@@ -569,6 +582,14 @@
569582
}
570583
# rubocop:enable Layout/LineLength
571584

585+
it 'matches in linear time' do
586+
if !Regexp.respond_to?(:linear_time?)
587+
skip 'Regexp.linear_time? method is only available on Ruby 3.3+'
588+
else
589+
expect(Regexp.linear_time?(regex)).to be true
590+
end
591+
end
592+
572593
key_matches.each do |key|
573594
context "given query string key #{key.inspect} and its value" do
574595
let(:str) { format('%<key>s=foo', { key: key }) }

0 commit comments

Comments
 (0)