diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index 4d30c4c149..759f526ff6 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -34,7 +34,7 @@ class Keg end def start_with_old_value?(key, text) - text.match?(/^#{@replacement_map.fetch(key)}/) + text.match?(/^#{@replacement_map.fetch(key).first}/) end sig { params(text: String).void } diff --git a/Library/Homebrew/test/keg_relocate/relocation_spec.rb b/Library/Homebrew/test/keg_relocate/relocation_spec.rb index ff0838c907..503aa3dd14 100644 --- a/Library/Homebrew/test/keg_relocate/relocation_spec.rb +++ b/Library/Homebrew/test/keg_relocate/relocation_spec.rb @@ -59,6 +59,17 @@ describe Keg::Relocation do REPLACED end + specify "#start_with_old_value?" do + relocation = setup_relocation + + expect(relocation.start_with_old_value?(:prefix, "#{HOMEBREW_PREFIX}/foo")).to be true + expect(relocation.start_with_old_value?(:prefix, "foo#{HOMEBREW_PREFIX}/bar")).to be false + expect(relocation.start_with_old_value?(:cellar, "#{HOMEBREW_CELLAR}/foo")).to be true + expect(relocation.start_with_old_value?(:cellar, "foo#{HOMEBREW_CELLAR}/bar")).to be false + expect(relocation.start_with_old_value?(:repository_placeholder, "@@HOMEBREW_REPOSITORY@@/foo")).to be true + expect(relocation.start_with_old_value?(:library_placeholder, "foo@@HOMEBREW_LIBRARY@@/bar")).to be false + end + specify "::path_regex" do expect(described_class.path_regex(prefix)).to eq escaped_prefix expect(described_class.path_regex("foo.bar")).to eq(/(?