Skip to content

Commit dd14d96

Browse files
committed
Lint/MixedRegexpCaptureTypes
Our URI regex combined both named and numbered capture groups, for example: (?<scheme>([^:\/?#]+):) Defines a named capture group 'scheme' with an inner capture group: ([^:\/?#]+) Ruby ignores numbered capture groups when they are mixed with named capture groups[1], so explicitly mark the inner ones as non-capturing using '?:' (?:[^:\/?#]+) This change was made to scheme, query and fragment. [1] https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Lint/MixedRegexpCaptureTypes
1 parent 6c1445a commit dd14d96

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,6 @@ Lint/ConstantDefinitionInBlock:
588588
Lint/MissingSuper:
589589
Enabled: false
590590

591-
Lint/MixedRegexpCaptureTypes:
592-
Exclude:
593-
- 'lib/puppet/util.rb'
594-
595591
Lint/NestedMethodDefinition:
596592
Exclude:
597593
- 'lib/puppet/pops/types/p_binary_type.rb'

lib/puppet/util.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def uri_to_path(uri)
332332
end
333333
module_function :uri_to_path
334334

335-
RFC_3986_URI_REGEX = /^(?<scheme>([^:\/?#]+):)?(?<authority>\/\/([^\/?#]*))?(?<path>[^?#]*)(\?(?<query>[^#]*))?(#(?<fragment>.*))?$/
335+
RFC_3986_URI_REGEX = /^(?<scheme>(?:[^:\/?#]+):)?(?<authority>\/\/(?:[^\/?#]*))?(?<path>[^?#]*)(?:\?(?<query>[^#]*))?(?:#(?<fragment>.*))?$/
336336

337337
# Percent-encodes a URI query parameter per RFC3986 - https://tools.ietf.org/html/rfc3986
338338
#

0 commit comments

Comments
 (0)