class Gem::UriFormatter
The UriFormatter handles URIs from user-input and escaping。
uf = Gem::UriFormatter.new 'example.com' p uf.normalize #=> 'http://example.com'
属性
Public Class Methods
Public Instance Methods
Source
# File lib/rubygems/uri_formatter.rb, line 29 def escape return unless @uri CGI.escape @uri end
Source
# File lib/rubygems/uri_formatter.rb, line 37 def normalize /^(https?|ftp|file):/i.match?(@uri) ? @uri : "http://#{@uri}" end
通过添加“http://”来规范化 URI,如果它缺失的话。
Source
# File lib/rubygems/uri_formatter.rb, line 44 def unescape return unless @uri CGI.unescape @uri end