diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-12-13 20:19:08 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2019-12-13 20:19:33 +0900 |
commit | 82cc2843a92b286cc13afd0860a4e111d4ea2a0b (patch) | |
tree | a517dedd40d35540930cea7732f5a36e76a549e8 /lib/rubygems/source.rb | |
parent | 26774351dc5f494253ba031e4bc453dc4dddb2cf (diff) | |
download | ruby-82cc2843a92b286cc13afd0860a4e111d4ea2a0b.tar.gz |
Prepare to release RubyGems 3.1.0 final version.
Diffstat (limited to 'lib/rubygems/source.rb')
-rw-r--r-- | lib/rubygems/source.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb index b0cce5bea5..8572cb1806 100644 --- a/lib/rubygems/source.rb +++ b/lib/rubygems/source.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true autoload :FileUtils, 'fileutils' -autoload :URI, 'uri' +require "rubygems/text" ## # A Source knows how to list and fetch gems from a RubyGems marshal index. # @@ -11,6 +11,7 @@ autoload :URI, 'uri' class Gem::Source include Comparable + include Gem::Text FILES = { # :nodoc: :released => 'specs', @@ -219,6 +220,11 @@ class Gem::Source end end + def typo_squatting?(host, distance_threshold=4) + return if @uri.host.nil? + levenshtein_distance(@uri.host, host) <= distance_threshold + end + end require 'rubygems/source/git' |