From 0d162a13f2651c4cc26475b0a73d7820f4ecdf13 Mon Sep 17 00:00:00 2001 From: DualFroz Date: Fri, 2 Oct 2026 16:18:47 +0200 Subject: [PATCH] Allow relative URI references for homepage and archive prefix-url --- res/satis-schema.json | 4 +- tests/Console/Command/BuildCommandTest.php | 48 ++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/res/satis-schema.json b/res/satis-schema.json index f22ff59..a44fe96 100644 --- a/res/satis-schema.json +++ b/res/satis-schema.json @@ -16,7 +16,7 @@ "homepage": { "type": "string", "description": "Homepage URL for the Repository.", - "format": "uri" + "format": "uri-reference" }, "require": { "type": "object", @@ -69,7 +69,7 @@ "prefix-url": { "type": "string", "description": "Location of the downloads.", - "format": "uri" + "format": "uri-reference" }, "checksum": { "type": "boolean", diff --git a/tests/Console/Command/BuildCommandTest.php b/tests/Console/Command/BuildCommandTest.php index 5fa4cfa..756e766 100644 --- a/tests/Console/Command/BuildCommandTest.php +++ b/tests/Console/Command/BuildCommandTest.php @@ -554,6 +554,54 @@ class BuildCommandTest extends TestCase self::assertTrue($method->invoke($command, $this->configPath)); } + /** + * @return array}> + */ + public static function dataRelativeUriReferences(): array + { + return [ + 'relative homepage' => [['homepage' => '/satis']], + 'relative archive prefix-url' => [['archive' => ['directory' => 'dist', 'prefix-url' => '/satis']]], + ]; + } + + /** + * @param array $overrides + */ + #[DataProvider('dataRelativeUriReferences')] + #[TestDox('check() accepts a relative URI reference for homepage and archive prefix-url')] + public function testCheckAcceptsRelativeUriReferences(array $overrides): void + { + $this->writeConfig(array_replace([ + 'name' => 'test/satis-repo', + 'homepage' => 'https://example.com', + 'repositories' => [], + ], $overrides)); + + $command = new BuildCommand(); + $method = new \ReflectionMethod($command, 'check'); + + self::assertTrue($method->invoke($command, $this->configPath)); + } + + #[TestDox('check() still rejects an archive prefix-url that is not a URI reference')] + public function testCheckRejectsInvalidPrefixUrl(): void + { + $this->writeConfig([ + 'name' => 'test/satis-repo', + 'homepage' => 'https://example.com', + 'repositories' => [], + 'archive' => ['directory' => 'dist', 'prefix-url' => 'not a uri'], + ]); + + $command = new BuildCommand(); + $method = new \ReflectionMethod($command, 'check'); + + $this->expectException(JsonValidationException::class); + + $method->invoke($command, $this->configPath); + } + #[TestDox('check() throws ParsingException for invalid JSON')] public function testCheckThrowsParsingExceptionForInvalidJson(): void {