Method: Wgit::Url#prefix_scheme
- Defined in:
- lib/wgit/url.rb
#prefix_scheme(scheme = :http) ⇒ Wgit::Url
Returns self having prefixed a scheme/protocol. Doesn't modify receiver. Returns self even if absolute (with scheme); therefore is idempotent.
351 352 353 354 355 356 357 358 359 360 |
# File 'lib/wgit/url.rb', line 351 def prefix_scheme(scheme = :http) unless %i[http https].include?(scheme) raise "scheme must be :http or :https, not :#{scheme}" end return self if absolute? && !scheme_relative? separator = scheme_relative? ? "" : "//" Wgit::Url.new("#{scheme}:#{separator}#{self}") end |