Skip to content

Commit f82fce1

Browse files
committed
Check for windows drive letter to not confuse it with a scheme.
1 parent fc5380a commit f82fce1

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lib/rdf/model/uri.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class URI
7676
IRI = Regexp.compile("^#{SCHEME}:(?:#{IHIER_PART})(?:\\?#{IQUERY})?(?:\\##{IFRAGMENT})?$").freeze
7777

7878
# Split an IRI into it's component parts
79+
# scheme, authority, path, query, fragment
7980
IRI_PARTS = /^(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(\?[^#]*)?(#.*)?$/.freeze
8081

8182
# Remove dot expressions regular expressions
@@ -872,6 +873,12 @@ def parse(value)
872873
parts = {}
873874
if matchdata = IRI_PARTS.match(value)
874875
scheme, authority, path, query, fragment = matchdata[1..-1]
876+
877+
if Gem.win_platform? && scheme.match?(/^[a-zA-Z]$/) && authority.to_s.empty?
878+
# A drive letter, not a scheme
879+
scheme, path = nil, "#{scheme}:#{path}"
880+
end
881+
875882
userinfo, hostport = authority.to_s.split('@', 2)
876883
hostport, userinfo = userinfo, nil unless hostport
877884
user, password = userinfo.to_s.split(':', 2)

0 commit comments

Comments
 (0)