Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Freeze URI constants.

  • Loading branch information...
commit 469cc3a7851f247ee21fba3c8fe37fd80cbf0aba 1 parent a9ed3bb
Gregg Kellogg gkellogg authored
Showing with 31 additions and 31 deletions.
  1. +31 −31 lib/rdf/model/uri.rb
62 lib/rdf/model/uri.rb
View
@@ -42,54 +42,54 @@ class URI
[\\u{A0000}-\\u{AFFFD}]|[\\u{B0000}-\\u{BFFFD}]|[\\u{C0000}-\\u{CFFFD}]|
[\\u{D0000}-\\u{DFFFD}]|[\\u{E0000}-\\u{EFFFD}]
EOS
- IPRIVATE = Regexp.compile("[\\uE000-\\uF8FF]|[\\u{F0000}-\\u{FFFFD}]|[\\u100000-\\u10FFFD]")
+ IPRIVATE = Regexp.compile("[\\uE000-\\uF8FF]|[\\u{F0000}-\\u{FFFFD}]|[\\u100000-\\u10FFFD]").freeze
end
- SCHEME = Regexp.compile("[A-za-z](?:[A-Za-z0-9+-\.])*")
- PORT = Regexp.compile("[0-9]*")
- IP_literal = Regexp.compile("\\[[0-9A-Fa-f:\\.]*\\]") # Simplified, no IPvFuture
- PCT_ENCODED = Regexp.compile("%[0-9A-Fa-f]{2}")
- GEN_DELIMS = Regexp.compile("[:/\\?\\#\\[\\]@]")
- SUB_DELIMS = Regexp.compile("[!\\$&'\\(\\)\\*\\+,;=]")
- RESERVED = Regexp.compile("(?:#{GEN_DELIMS}|#{SUB_DELIMS})")
- UNRESERVED = Regexp.compile("[A-Za-z0-9]|-|\\.|_|~")
+ SCHEME = Regexp.compile("[A-za-z](?:[A-Za-z0-9+-\.])*").freeze
+ PORT = Regexp.compile("[0-9]*").freeze
+ IP_literal = Regexp.compile("\\[[0-9A-Fa-f:\\.]*\\]").freeze # Simplified, no IPvFuture
+ PCT_ENCODED = Regexp.compile("%[0-9A-Fa-f]{2}").freeze
+ GEN_DELIMS = Regexp.compile("[:/\\?\\#\\[\\]@]").freeze
+ SUB_DELIMS = Regexp.compile("[!\\$&'\\(\\)\\*\\+,;=]").freeze
+ RESERVED = Regexp.compile("(?:#{GEN_DELIMS}|#{SUB_DELIMS})").freeze
+ UNRESERVED = Regexp.compile("[A-Za-z0-9]|-|\\.|_|~").freeze
if RUBY_VERSION >= '1.9'
- IUNRESERVED = Regexp.compile("[A-Za-z0-9]|-|\\.|_|~|#{UCSCHAR}")
+ IUNRESERVED = Regexp.compile("[A-Za-z0-9]|-|\\.|_|~|#{UCSCHAR}").freeze
else
- IUNRESERVED = Regexp.compile("[A-Za-z0-9]|-|\\.|_|~")
+ IUNRESERVED = Regexp.compile("[A-Za-z0-9]|-|\\.|_|~").freeze
end
- IPCHAR = Regexp.compile("(?:#{IUNRESERVED}|#{PCT_ENCODED}|#{SUB_DELIMS}|:|@)")
+ IPCHAR = Regexp.compile("(?:#{IUNRESERVED}|#{PCT_ENCODED}|#{SUB_DELIMS}|:|@)").freeze
if RUBY_VERSION >= '1.9'
- IQUERY = Regexp.compile("(?:#{IPCHAR}|#{IPRIVATE}|/|\\?)*")
+ IQUERY = Regexp.compile("(?:#{IPCHAR}|#{IPRIVATE}|/|\\?)*").freeze
else
- IQUERY = Regexp.compile("(?:#{IPCHAR}|/|\\?)*")
+ IQUERY = Regexp.compile("(?:#{IPCHAR}|/|\\?)*").freeze
end
- IFRAGMENT = Regexp.compile("(?:#{IPCHAR}|/|\\?)*")
+ IFRAGMENT = Regexp.compile("(?:#{IPCHAR}|/|\\?)*").freeze.freeze
- ISEGMENT = Regexp.compile("(?:#{IPCHAR})*")
- ISEGMENT_NZ = Regexp.compile("(?:#{IPCHAR})+")
- ISEGMENT_NZ_NC = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS})|@)+")
+ ISEGMENT = Regexp.compile("(?:#{IPCHAR})*").freeze
+ ISEGMENT_NZ = Regexp.compile("(?:#{IPCHAR})+").freeze
+ ISEGMENT_NZ_NC = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS})|@)+").freeze
- IPATH_ABEMPTY = Regexp.compile("(?:/#{ISEGMENT})*")
- IPATH_ABSOLUTE = Regexp.compile("/(?:(?:#{ISEGMENT_NZ})(/#{ISEGMENT})*)?")
- IPATH_NOSCHEME = Regexp.compile("(?:#{ISEGMENT_NZ_NC})(?:/#{ISEGMENT})*")
- IPATH_ROOTLESS = Regexp.compile("(?:#{ISEGMENT_NZ})(?:/#{ISEGMENT})*")
- IPATH_EMPTY = Regexp.compile("")
+ IPATH_ABEMPTY = Regexp.compile("(?:/#{ISEGMENT})*").freeze
+ IPATH_ABSOLUTE = Regexp.compile("/(?:(?:#{ISEGMENT_NZ})(/#{ISEGMENT})*)?").freeze
+ IPATH_NOSCHEME = Regexp.compile("(?:#{ISEGMENT_NZ_NC})(?:/#{ISEGMENT})*").freeze
+ IPATH_ROOTLESS = Regexp.compile("(?:#{ISEGMENT_NZ})(?:/#{ISEGMENT})*").freeze
+ IPATH_EMPTY = Regexp.compile("").freeze
- IREG_NAME = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS}))*")
- IHOST = Regexp.compile("(?:#{IP_literal})|(?:#{IREG_NAME})")
- IUSERINFO = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS})|:)*")
- IAUTHORITY = Regexp.compile("(?:#{IUSERINFO}@)?#{IHOST}(?::#{PORT})?")
+ IREG_NAME = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS}))*").freeze
+ IHOST = Regexp.compile("(?:#{IP_literal})|(?:#{IREG_NAME})").freeze
+ IUSERINFO = Regexp.compile("(?:(?:#{IUNRESERVED})|(?:#{PCT_ENCODED})|(?:#{SUB_DELIMS})|:)*").freeze
+ IAUTHORITY = Regexp.compile("(?:#{IUSERINFO}@)?#{IHOST}(?::#{PORT})?").freeze
- IRELATIVE_PART = Regexp.compile("(?:(?://#{IAUTHORITY}(?:#{IPATH_ABEMPTY}))|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_NOSCHEME})|(?:#{IPATH_EMPTY}))")
- IRELATIVE_REF = Regexp.compile("^#{IRELATIVE_PART}(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$")
+ IRELATIVE_PART = Regexp.compile("(?:(?://#{IAUTHORITY}(?:#{IPATH_ABEMPTY}))|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_NOSCHEME})|(?:#{IPATH_EMPTY}))").freeze
+ IRELATIVE_REF = Regexp.compile("^#{IRELATIVE_PART}(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze
- IHIER_PART = Regexp.compile("(?:(?://#{IAUTHORITY}#{IPATH_ABEMPTY})|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_ROOTLESS})|(?:#{IPATH_EMPTY}))")
- IRI = Regexp.compile("^#{SCHEME}:(?:#{IHIER_PART})(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$")
+ IHIER_PART = Regexp.compile("(?:(?://#{IAUTHORITY}#{IPATH_ABEMPTY})|(?:#{IPATH_ABSOLUTE})|(?:#{IPATH_ROOTLESS})|(?:#{IPATH_EMPTY}))").freeze
+ IRI = Regexp.compile("^#{SCHEME}:(?:#{IHIER_PART})(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze
##
# @return [RDF::Util::Cache]
Please sign in to comment.
Something went wrong with that request. Please try again.