Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that regexps match in linear time #3042

Merged
merged 5 commits into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }
p-datadog marked this conversation as resolved.
Show resolved Hide resolved

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
Loading