Skip to content

Commit

Permalink
Removes unnecessary dot in regexp
Browse files Browse the repository at this point in the history
A string S matches ([.]|\b)html if an only if matches \bhtml:

  * If S matches [.]html, then it matches \bhtml.

  * If S matches \bhtml, then it matches \bhtml.

Reciprocally:

  * If S matches \bhtml, then it matches ([.]|\b)html.

The character class can be removed, and since we are on it we remove the
group too so that it is clear to a reader of the code that there is no
grouping going on.

References #35166.
  • Loading branch information
fxn committed Feb 28, 2019
1 parent 81710da commit 42ca13a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion actionview/lib/action_view/helpers/translation_helper.rb
Expand Up @@ -138,7 +138,7 @@ def scope_key_by_partial(key)
end

def html_safe_translation_key?(key)
/([_.]|\b)html\z/.match?(key.to_s)
/(?:_|\b)html\z/.match?(key.to_s)
end
end
end
Expand Down

0 comments on commit 42ca13a

Please sign in to comment.