Skip to content

Commit

Permalink
Added better URI validation tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Aug 2, 2024
1 parent abb2d3d commit 863a667
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lint/wordlists_yml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@
end

describe ":url" do
it "must be a http:// or https:// URL" do
expect(attributes[:url]).to match(/\A#{URI::DEFAULT_PARSER.make_regexp(%w[http https])}\z/)
it "must be a valid http:// or https:// URL" do
uri = URI(attributes[:url])

expect(uri).to be_kind_of(URI::HTTP).or(be_kind_of(URI::HTTPS))
expect(uri.host).to_not be(nil), "URI does not have a host name"
expect(uri.host).to_not be_empty, "URI does not have a host name"
expect(uri.port).to_not be(nil), "URI does not have a port number"
expect(uri.path).to_not be(nil), "URI does not have a path"
expect(uri.path).to_not be_empty, "URI does not have a path"
end
end

Expand Down

0 comments on commit 863a667

Please sign in to comment.