discourse/spec/lib/onebox/engine/steam_store_onebox_spec.rb
Blake Erickson 17116c440b
SECURITY: Restrict allowed URL patterns
Restrict allowed URL patterns for oneboxes.
2025-02-04 13:32:34 -03:00

25 lines
867 B
Ruby
Vendored

#frozen_string_literal: true
RSpec.describe Onebox::Engine::SteamStoreOnebox do
describe ".===" do
it "matches valid Steam Store app URL" do
valid_url = URI("https://store.steampowered.com/app/123456")
expect(described_class === valid_url).to eq(true)
end
it "does not match URL with invalid path" do
invalid_path_url = URI("https://store.steampowered.com/invalid/123456")
expect(described_class === invalid_path_url).to eq(false)
end
it "does not match unrelated domain" do
unrelated_url = URI("https://example.com/app/123456")
expect(described_class === unrelated_url).to eq(false)
end
it "does not match URL with extra domain" do
malicious_url = URI("https://store.steampowered.com.malicious.com/app/123456")
expect(described_class === malicious_url).to eq(false)
end
end
end