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 6ecdfa9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/html_proofer/attribute/url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,14 @@ 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.to_s
else
parsed_url.display_uri.to_s
end
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 6ecdfa9

Please sign in to comment.