Skip to content
This repository has been archived by the owner on Mar 28, 2021. It is now read-only.

Commit

Permalink
bug fix createFromComponents named constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jan 16, 2017
1 parent ae5f4ec commit 1d0ad31
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

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

## 1.0.1 - 2017-01-16

### Added

- None

### Fixed

- `League\Uri\Schemes\Http::createFromComponents` with invalid Host

### Deprecated

- None

### Removed

- None

## 1.0.0 - 2017-01-04

### Added
Expand Down
4 changes: 4 additions & 0 deletions src/AbstractUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ public static function createFromComponents(array $components): self
'port' => null, 'path' => '', 'query' => null, 'fragment' => null,
];

if (null !== $components['host'] && !self::getParser()->isHost($components['host'])) {
throw UriException::createFromInvalidHost($components['host']);
}

return new static(
$components['scheme'],
$components['user'],
Expand Down
7 changes: 7 additions & 0 deletions tests/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ public function testCreateFromComponents()
Http::createFromString($uri)
);
}

public function testCreateFromComponentsTrowsException()
{
$this->expectException(ParserException::class);
Http::createFromComponents(['host' => '[127.0.0.1]']);
}

public function testInvalidSetterThrowException()
{
$this->expectException(BadMethodCallException::class);
Expand Down

0 comments on commit 1d0ad31

Please sign in to comment.