File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4242 "ext-pcre" : " *" ,
4343 "ext-spl" : " *" ,
4444
45+ "guzzlehttp/psr7" : " ~2.8" ,
4546 "psr/clock" : " ~1.0" ,
4647 "simplesamlphp/assert" : " ~1.9" ,
4748 "simplesamlphp/composer-xmlprovider-installer" : " ~1.2"
Original file line number Diff line number Diff line change 44
55namespace SimpleSAML \XMLSchema \Type ;
66
7+ use GuzzleHttp \Psr7 \Uri ;
8+ use GuzzleHttp \Psr7 \UriNormalizer ;
79use SimpleSAML \XML \Assert \Assert ;
810use SimpleSAML \XMLSchema \Exception \SchemaViolationException ;
911use SimpleSAML \XMLSchema \Type \Interface \AbstractAnySimpleType ;
12+ use SimpleSAML \XMLSchema \Type \Interface \ValueTypeInterface ;
1013
1114/**
1215 * @package simplesaml/xml-common
@@ -37,4 +40,23 @@ protected function validateValue(string $value): void
3740 {
3841 Assert::validAnyURI ($ value , SchemaViolationException::class);
3942 }
43+
44+
45+ /**
46+ * Compare the value to another one
47+ *
48+ * @param \SimpleSAML\XMLSchema\Type\Interface\ValueTypeInterface|string $other
49+ * @return bool
50+ */
51+ public function equals (ValueTypeInterface |string $ other ): bool
52+ {
53+ if (is_string ($ other )) {
54+ $ other = static ::fromString ($ other );
55+ }
56+
57+ $ selfUri = new Uri ($ this ->getValue ());
58+ $ otherUri = new Uri ($ other ->getValue ());
59+
60+ return UriNormalizer::isEquivalent ($ selfUri , $ otherUri );
61+ }
4062}
Original file line number Diff line number Diff line change @@ -48,11 +48,19 @@ public function testEquals(): void
4848 $ this ->assertTrue (AnyURIValue::fromString ('hello ' )->equals (AnyURIValue::fromString ('hello ' )));
4949 $ this ->assertTrue (AnyURIValue::fromString ('hello ' )->equals (StringValue::fromString ('hello ' )));
5050 $ this ->assertTrue (AnyURIValue::fromString ('hello ' )->equals ('hello ' ));
51+ $ this ->assertTrue (
52+ AnyURIValue::fromString ('https://simplesamlphp.org/index.html ' )
53+ ->equals ('https://simplesamlphp.org:443/index.html ' ),
54+ );
5155
5256 // Assert that two different values are not equal
5357 $ this ->assertFalse (AnyURIValue::fromString ('hello ' )->equals (AnyURIValue::fromString ('world ' )));
5458 $ this ->assertFalse (AnyURIValue::fromString ('hello ' )->equals (StringValue::fromString ('world ' )));
5559 $ this ->assertFalse (AnyURIValue::fromString ('hello ' )->equals ('world ' ));
60+ $ this ->assertFalse (
61+ AnyURIValue::fromString ('https://simplesamlphp.org:8443/index.html ' )
62+ ->equals ('https://simplesamlphp.org:443/index.html ' ),
63+ );
5664 }
5765
5866
You can’t perform that action at this time.
0 commit comments