@@ -888,6 +888,34 @@ private static function formatFilePath(string $path): string
888888 );
889889 }
890890
891+ /**
892+ * assert the URI internal state is valid.
893+ *
894+ * @link https://tools.ietf.org/html/rfc3986#section-3
895+ * @link https://tools.ietf.org/html/rfc3986#section-3.3
896+ *
897+ * @throws SyntaxError if the URI is in an invalid state, according to RFC3986
898+ */
899+ private function assertValidRfc3986Uri (): void
900+ {
901+ if (null !== $ this ->authority && ('' !== $ this ->path && '/ ' !== $ this ->path [0 ])) {
902+ throw new SyntaxError ('If an authority is present the path must be empty or start with a `/`. ' );
903+ }
904+
905+ if (null === $ this ->authority && str_starts_with ($ this ->path , '// ' )) {
906+ throw new SyntaxError ('If there is no authority the path ` ' . $ this ->path . '` cannot start with a `//`. ' );
907+ }
908+
909+ $ pos = strpos ($ this ->path , ': ' );
910+ if (null === $ this ->authority
911+ && null === $ this ->scheme
912+ && false !== $ pos
913+ && !str_contains (substr ($ this ->path , 0 , $ pos ), '/ ' )
914+ ) {
915+ throw new SyntaxError ('In absence of a scheme and an authority the first path segment cannot contain a colon (":") character. ' );
916+ }
917+ }
918+
891919 /**
892920 * assert the URI scheme is valid
893921 *
@@ -946,34 +974,6 @@ private function assertValidState(): void
946974 } || throw new SyntaxError ('The uri ` ' .$ this ->uriAsciiString .'` is invalid for the ` ' .$ this ->scheme .'` scheme. ' );
947975 }
948976
949- /**
950- * assert the URI internal state is valid.
951- *
952- * @link https://tools.ietf.org/html/rfc3986#section-3
953- * @link https://tools.ietf.org/html/rfc3986#section-3.3
954- *
955- * @throws SyntaxError if the URI is in an invalid state, according to RFC3986
956- */
957- private function assertValidRfc3986Uri (): void
958- {
959- if (null !== $ this ->authority && ('' !== $ this ->path && '/ ' !== $ this ->path [0 ])) {
960- throw new SyntaxError ('If an authority is present the path must be empty or start with a `/`. ' );
961- }
962-
963- if (null === $ this ->authority && str_starts_with ($ this ->path , '// ' )) {
964- throw new SyntaxError ('If there is no authority the path ` ' . $ this ->path . '` cannot start with a `//`. ' );
965- }
966-
967- $ pos = strpos ($ this ->path , ': ' );
968- if (null === $ this ->authority
969- && null === $ this ->scheme
970- && false !== $ pos
971- && !str_contains (substr ($ this ->path , 0 , $ pos ), '/ ' )
972- ) {
973- throw new SyntaxError ('In absence of a scheme and an authority the first path segment cannot contain a colon (":") character. ' );
974- }
975- }
976-
977977 private function isValidBlob (): bool
978978 {
979979 static $ regexpUuidRfc4122 = '/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i ' ;
0 commit comments