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 {