Skip to content

Commit

Permalink
Prepare 7.4.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Nov 24, 2023
1 parent 81796a5 commit 3f8588d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 40 deletions.
2 changes: 1 addition & 1 deletion components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All Notable changes to `League\Uri\Components` will be documented in this file

## Next - TBD
## [7.4.0](https://github.com/thephpleague/uri-components/compare/7.3.0...7.4.0) - 2023-11-23

### Added

Expand Down
1 change: 0 additions & 1 deletion components/Components/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use League\Uri\QueryString;
use Psr\Http\Message\UriInterface as Psr7UriInterface;
use Stringable;

use Traversable;

use function array_column;
Expand Down
20 changes: 1 addition & 19 deletions interfaces/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,7 @@

All Notable changes to `League\Uri\Interfaces` will be documented in this file

## Next - TBD

### Added

- None

### Fixed

- None

### Deprecated

- None

### Removed

- None

## [7.3.0](https://github.com/thephpleague/uri-interfaces/compare/7.2.0...7.3.0) - 2023-09-09
## [Next](https://github.com/thephpleague/uri-interfaces/compare/7.2.0...7.3.0) - 2023-09-09

### Added

Expand Down
2 changes: 1 addition & 1 deletion uri/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All Notable changes to `League\Uri` will be documented in this file

## Next - TBD
## [7.4.0](https://github.com/thephpleague/uri/compare/7.3.0...7.4.0) - 2023-09-09

### Added

Expand Down
37 changes: 19 additions & 18 deletions uri/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,29 +521,30 @@ public static function fromData(string $data, string $mimetype = '', string $par
default => throw new SyntaxError('Invalid mimeType, `'.$mimetype.'`.'),
};

if ('' != $parameters) {
if (str_starts_with($parameters, ';')) {
$parameters = substr($parameters, 1);
}

$validateParameter = function (string $parameter): bool {
$properties = explode('=', $parameter);
if ('' === $parameters) {
return self::fromComponents([
'scheme' => 'data',
'path' => self::formatDataPath($mimetype.','.rawurlencode($data)),
]);
}

return 2 != count($properties) || 'base64' === strtolower($properties[0]);
};
$isInvalidParameter = static function (string $parameter): bool {
$properties = explode('=', $parameter);

$params = array_filter(explode(';', $parameters));
if ([] !== array_filter($params, $validateParameter(...))) {
throw new SyntaxError(sprintf('Invalid mediatype parameters, `%s`.', $parameters));
}
return 2 !== count($properties) || 'base64' === strtolower($properties[0]);
};

$parameters = ';'.$parameters;
if (str_starts_with($parameters, ';')) {
$parameters = substr($parameters, 1);
}

return self::fromComponents([
'scheme' => 'data',
'path' => self::formatDataPath($mimetype.$parameters.','.rawurlencode($data)),
]);
return match ([]) {
array_filter(explode(';', $parameters), $isInvalidParameter) => self::fromComponents([
'scheme' => 'data',
'path' => self::formatDataPath($mimetype.';'.$parameters.','.rawurlencode($data)),
]),
default => throw new SyntaxError(sprintf('Invalid mediatype parameters, `%s`.', $parameters))
};
}

/**
Expand Down

0 comments on commit 3f8588d

Please sign in to comment.