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

Support multiple email addresses in mailto #797

Merged
merged 3 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ task :proof_readme do
require "html-proofer"
require "redcarpet"

renderer = Redcarpet::Render::HTML.new(\
renderer = Redcarpet::Render::HTML.new(
with_toc_data: true,
)
redcarpet = Redcarpet::Markdown.new(renderer)
Expand Down
3 changes: 2 additions & 1 deletion lib/html_proofer/check/links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def handle_mailto
"#{@link.url.raw_attribute} contains no email address",
element: @link,
) unless ignore_empty_mailto?
elsif !/#{URI::MailTo::EMAIL_REGEXP}/o.match?(@link.url.path)
# eg., if any do not match a valid URL
elsif @link.url.path.split(",").any? { |email| !/#{URI::MailTo::EMAIL_REGEXP}/o.match?(email) }
add_failure(
"#{@link.url.raw_attribute} contains an invalid email address",
element: @link,
Expand Down
4 changes: 2 additions & 2 deletions lib/html_proofer/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Log

def initialize(log_level)
@logger = Yell.new(
format: false, \
format: false,
name: "HTMLProofer", \
level: "gte.#{log_level}",
) do |l|
Expand Down Expand Up @@ -41,7 +41,7 @@ def colorize(level, message)
:red
end

if (STDOUT_LEVELS.include?(level) && $stdout.isatty) || \
if (STDOUT_LEVELS.include?(level) && $stdout.isatty) ||
(STDERR_LEVELS.include?(level) && $stderr.isatty)
Rainbow(message).send(color)
else
Expand Down
4 changes: 2 additions & 2 deletions lib/html_proofer/reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def initialize(logger: nil)
end

def failures=(failures)
@failures = failures.group_by(&:check_name) \
.transform_values { |issues| issues.sort_by { |issue| [issue.path, issue.line] } } \
@failures = failures.group_by(&:check_name)
.transform_values { |issues| issues.sort_by { |issue| [issue.path, issue.line] } }
.sort
end

Expand Down
2 changes: 1 addition & 1 deletion lib/html_proofer/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module HTMLProofer
VERSION = "5.0.6"
VERSION = "5.0.7"
end
5 changes: 5 additions & 0 deletions spec/html-proofer/fixtures/links/multiple_mailto_links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
<a href="mailto:[email protected],[email protected],[email protected]">Mail me</a>.
</body>
</html>
6 changes: 6 additions & 0 deletions spec/html-proofer/links_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@
expect(proofer.failed_checks).to(eq([]))
end

it "accepts multiple mailto links" do
ignorable_links = File.join(FIXTURES_DIR, "links", "multiple_mailto_links.html")
proofer = run_proofer(ignorable_links, :file)
expect(proofer.failed_checks).to(eq([]))
end

it "ignores blank mailto links when configured to allow them" do
blank_mail_to_link = File.join(FIXTURES_DIR, "links", "blank_mailto_link.html")
proofer = run_proofer(blank_mail_to_link, :file, ignore_empty_mailto: true)
Expand Down