Skip to content

Commit

Permalink
Merge pull request #797 from gjtorikian/multiple-mailtos
Browse files Browse the repository at this point in the history
Support multiple email addresses in `mailto`
  • Loading branch information
gjtorikian authored Apr 18, 2023
2 parents bcc4bac + ad73180 commit df99bc4
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
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:test@test.org,test1@cs.edu,test0@cs.wisc.edu">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

1 comment on commit df99bc4

@MinKhant21a
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.