0
0
Fork 0

Autofix Rubocop Regex Style rules (#23690)

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Nick Schonning 2023-06-06 08:50:51 -04:00 committed by GitHub
parent 9a653899e9
commit c66250abf1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 46 additions and 92 deletions

View file

@ -7,15 +7,15 @@ class LinkDetailsExtractor
# Some publications wrap their JSON-LD data in their <script> tags
# in commented-out CDATA blocks, they need to be removed before
# attempting to parse JSON
CDATA_JUNK_PATTERN = %r{^[\s]*(
(/\*[\s]*<!\[CDATA\[[\s]*\*/) # Block comment style opening
CDATA_JUNK_PATTERN = %r{^\s*(
(/\*\s*<!\[CDATA\[\s*\*/) # Block comment style opening
|
(//[\s]*<!\[CDATA\[) # Single-line comment style opening
(//\s*<!\[CDATA\[) # Single-line comment style opening
|
(/\*[\s]*\]\]>[\s]*\*/) # Block comment style closing
(/\*\s*\]\]>\s*\*/) # Block comment style closing
|
(//[\s]*\]\]>) # Single-line comment style closing
)[\s]*$}x
(//\s*\]\]>) # Single-line comment style closing
)\s*$}x
class StructuredData
SUPPORTED_TYPES = %w(
@ -204,7 +204,7 @@ class LinkDetailsExtractor
def host_to_url(str)
return if str.blank?
str.start_with?(/https?:\/\//) ? str : "http://#{str}"
str.start_with?(%r{https?://}) ? str : "http://#{str}"
end
def valid_url_or_nil(str, same_origin_only: false)

View file

@ -3,7 +3,7 @@
class PlainTextFormatter
include ActionView::Helpers::TextHelper
NEWLINE_TAGS_RE = /(<br \/>|<br>|<\/p>)+/
NEWLINE_TAGS_RE = %r{(<br />|<br>|</p>)+}
attr_reader :text, :local

View file

@ -7,18 +7,18 @@ class TagManager
include RoutingHelper
def web_domain?(domain)
domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.web_domain).zero?
domain.nil? || domain.delete('/').casecmp(Rails.configuration.x.web_domain).zero?
end
def local_domain?(domain)
domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.local_domain).zero?
domain.nil? || domain.delete('/').casecmp(Rails.configuration.x.local_domain).zero?
end
def normalize_domain(domain)
return if domain.nil?
uri = Addressable::URI.new
uri.host = domain.gsub(/[\/]/, '')
uri.host = domain.delete('/')
uri.normalized_host
end

View file

@ -5,7 +5,7 @@ class TextFormatter
include ERB::Util
include RoutingHelper
URL_PREFIX_REGEX = /\A(https?:\/\/(www\.)?|xmpp:)/
URL_PREFIX_REGEX = %r{\A(https?://(www\.)?|xmpp:)}
DEFAULT_REL = %w(nofollow noopener noreferrer).freeze

View file

@ -13,7 +13,7 @@ class WebfingerResource
case resource
when /\Ahttps?/i
username_from_url
when /\@/
when /@/
username_from_acct
else
raise InvalidRequest