Module: TripletInterruptus
- Included in:
- URI::Parser, URI::RFC3986_Parser
- Defined in:
- lib/uri/triplets.rb
Overview
A SCP Triplet is not a canonical URI. It doesn’t follow any RFCs that I’ve been able to find, and it’s difficult to reason about if you try to force it into a URI::Generic as-is. TripletInterruptus provides helper methods that preserve the upstream behavior of URI::Generic but extend it just enough that it doesn’t choke on SCP Triplets if they’re passed.
Constant Summary collapse
- TRIPLET =
Determine if a string can be teased apart into URI-like components
%r{\A(?:(?<userinfo>.+)@+)?(?<host>[\w.-]+):(?<path>.*)\z}.freeze
- SCHEME =
Determine if a string is prefixed with a URI scheme like http:// or ssh://
%r{\A(?:(?<scheme>[a-z]+)://)}.freeze
Instance Method Summary collapse
Instance Method Details
#parse(uri) ⇒ Object
68 69 70 71 72 |
# File 'lib/uri/triplets.rb', line 68 def parse(uri) return build_triplet(uri) if triplet?(uri) super(uri) end |
#split(uri) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/uri/triplets.rb', line 74 def split(uri) return super(uri) unless triplet?(uri) parts = parse_triplet(uri) [nil, parts[:userinfo], parts[:host], nil, nil, parts[:path], nil, nil, nil] end |