Skip to content

Commit

Permalink
Merge 9cb1f77 into 7202cd8
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Jan 27, 2023
2 parents 7202cd8 + 9cb1f77 commit 8968c15
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 3 deletions.
7 changes: 5 additions & 2 deletions library/packages/src/lib/y2packager/zypp_url.rb
Expand Up @@ -136,7 +136,7 @@ def expanded
# @return [String]
def inspect
# Prevent SimpleDelegator from forwarding this to the wrapped URI object
"#<#{self.class}:#{object_id}} @uri=#{uri.inspect}>"
"#<#{self.class}:#{object_id} @uri=#{uri.inspect}>"
end

# Compares two URLs
Expand All @@ -146,7 +146,10 @@ def inspect
# object is introduced to replace an existing URI one.
def ==(other)
if other.is_a?(URI::Generic)
uri == other
uri == other ||
# zypp will normalize dir:///foo to dir:/foo
# https://github.com/openSUSE/libzypp/issues/441
uri == URI(other.to_s.sub(":///", ":/"))
elsif other.class == self.class
uri == other.uri
else
Expand Down
60 changes: 60 additions & 0 deletions library/packages/test/y2packager/zypp_url_test.rb
@@ -0,0 +1,60 @@
#!/usr/bin/env rspec

require_relative "../test_helper"
require "uri"
require "y2packager/zypp_url"

describe Y2Packager::ZyppUrl do
let(:https_s) { "https://example.com/path" }

describe "#==" do
it "returns true for the same ZyppUrl" do
z = described_class.new(https_s)
z2 = described_class.new(https_s.dup)
expect(z == z2).to eq(true)
end

it "returns false for a different ZyppUrl" do
z = described_class.new(https_s)
z2 = described_class.new("https://example.com/different")
expect(z == z2).to eq(false)
end

it "returns true for the same URI::Generic" do
z = described_class.new(https_s)
u = URI(https_s.dup)
expect(z == u).to eq(true)
end

it "returns true for URI::Generic if the only difference is undefine/empty authority" do
s1 = "dir:/foo"
s3 = "dir:///foo"
u1 = URI(s1)
u3 = URI(s3)
z1 = described_class.new(s1)

expect(z1 == u1).to eq(true)
expect(z1 == u3).to eq(true)
end

it "returns false for a different URI::Generic" do
z = described_class.new(https_s)
u = URI("https://example.com/different")
expect(z == u).to eq(false)
end

# NOTE: even a String which looks the same will return false
it "returns false for a different class" do
u = described_class.new(https_s)

expect(u == https_s).to eq(false)
end
end

describe "#inspect" do
it "returns a string" do
z = described_class.new(https_s)
expect(z.inspect).to be_a(String)
end
end
end
6 changes: 6 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Jan 27 10:13:29 UTC 2023 - Martin Vidner <mvidner@suse.com>

- Allow dir:///foo to equal dir:/foo (bsc#1207239)
- 4.5.23

-------------------------------------------------------------------
Wed Jan 18 12:52:10 UTC 2023 - Ludwig Nussel <lnussel@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.5.22
Version: 4.5.23

Release: 0
Summary: YaST2 Main Package
Expand Down

0 comments on commit 8968c15

Please sign in to comment.