Sha256: 71bb3044ec2f68240e2dae45a87e5fb1fc63284bb613bfd3f7e1fe19ea72da13
Contents?: true
Size: 796 Bytes
Versions: 17
Compression:
Stored size: 796 Bytes
Contents
module Steep module PathHelper module_function URIParser = URI::RFC2396_Parser.new() def to_pathname(uri, dosish: Gem.win_platform?) uri = URI.parse(uri) if uri.scheme == "file" path = uri.path or raise path.sub!(%r{^/([a-zA-Z])(:|%3A)//?}i, '\1:/') if dosish path = URIParser.unescape(path) Pathname(path) end end def to_pathname!(uri, dosish: Gem.win_platform?) to_pathname(uri, dosish: dosish) or raise "Cannot translate a URI to pathname: #{uri}" end def to_uri(path, dosish: Gem.win_platform?) str_path = path.to_s if dosish str_path.insert(0, "/") if str_path[0] != "/" end str_path = URIParser.escape(str_path) URI::File.build(path: str_path) end end end
Version data entries
17 entries across 17 versions & 3 rubygems