Ruby's URI library breaks a URL string into parts without making a network request.

URI Parsing

uri_parsing.rb
require "uri"

raw_url = 
uri = URI.parse(raw_url)

scheme = uri.scheme
host = uri.host
path = uri.path
query = uri.query || "none"

puts "scheme=#{scheme}"
puts "host=#{host}"
puts "path=#{path}"
puts "query=#{query}"
require "uri"

raw_url = 
uri = URI.parse(raw_url)

scheme = uri.scheme
host = uri.host
path = uri.path
query = uri.query || "none"

puts "scheme=#{scheme}"
puts "host=#{host}"
puts "path=#{path}"
puts "query=#{query}"
require "uri"

raw_url = 
uri = URI.parse(raw_url)

scheme = uri.scheme
host = uri.host
path = uri.path
query = uri.query || "none"

puts "scheme=#{scheme}"
puts "host=#{host}"
puts "path=#{path}"
puts "query=#{query}"
uri A `URI` object exposes pieces such as the scheme, host, path, and query string.