Skip to content

Commit 460279d

Browse files
authored
Merge pull request #198 from Earlopain/uri-parser-memo
Move uri parser to constant
2 parents 6c719da + 42ead60 commit 460279d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/global_id/uri/gid.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class InvalidModelIdError < URI::InvalidComponentError; end
3636
COMPOSITE_MODEL_ID_MAX_SIZE = 20
3737
COMPOSITE_MODEL_ID_DELIMITER = "/"
3838

39+
URI_PARSER = URI::RFC2396_Parser.new # :nodoc:
40+
3941
class << self
4042
# Validates +app+'s as URI hostnames containing only alphanumeric characters
4143
# and hyphens. An ArgumentError is raised if +app+ is invalid.
@@ -62,7 +64,7 @@ def validate_app(app)
6264
# URI.parse('gid://bcx') # => URI::GID instance
6365
# URI::GID.parse('gid://bcx/') # => raises URI::InvalidComponentError
6466
def parse(uri)
65-
generic_components = URI.split(uri) << URI::RFC2396_Parser.new << true # RFC2396 parser, true arg_check
67+
generic_components = URI.split(uri) << URI_PARSER << true # RFC2396 parser, true arg_check
6668
new(*generic_components)
6769
end
6870

0 commit comments

Comments
 (0)