mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
28918eac58
several bugs in RubyGems 2.2.0.preview.1. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
29 lines
403 B
Ruby
29 lines
403 B
Ruby
require 'cgi'
|
|
require 'uri'
|
|
|
|
class Gem::UriFormatter
|
|
attr_reader :uri
|
|
|
|
def initialize uri
|
|
@uri = uri
|
|
end
|
|
|
|
def escape
|
|
return unless @uri
|
|
CGI.escape @uri
|
|
end
|
|
|
|
##
|
|
# Normalize the URI by adding "http://" if it is missing.
|
|
|
|
def normalize
|
|
(@uri =~ /^(https?|ftp|file):/i) ? @uri : "http://#{@uri}"
|
|
end
|
|
|
|
def unescape
|
|
return unless @uri
|
|
CGI.unescape @uri
|
|
end
|
|
|
|
end
|
|
|