Skip to content

Commit

Permalink
Remove unnecessary regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
gjtorikian committed May 6, 2024
1 parent eecf75d commit 61535f1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/html_proofer/attribute/url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,15 @@ def without_hash
@url.to_s.sub(/##{hash}/, "")
end

# catch any obvious issues, like strings in port numbers
# catch any obvious issues
private def clean_url!
return if @url =~ /^([!#{Regexp.last_match(0)}-;=?-\[\]_a-z~]|%[0-9a-fA-F]{2})+$/

@url = Addressable::URI.parse(@url).normalize.to_s
parsed_url = Addressable::URI.parse(@url)
@url = if parsed_url.scheme.nil?
parsed_url
else
parsed_url.normalize
end.to_s
rescue Addressable::URI::InvalidURIError # rubocop:disable Lint/SuppressedException; error will be reported at check time
end

private def swap_urls!
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 61535f1

Please sign in to comment.