Skip to content

Commit

Permalink
Merge pull request #205 from thephpleague/hotfix/is-cross-origin
Browse files Browse the repository at this point in the history
Fix isCrossOrigin implementation
  • Loading branch information
nyamsprod committed Jun 29, 2022
2 parents 9bae56e + b459b34 commit 2d7c87a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@

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

## [6.7.0](https://github.com/thephpleague/uri/compare/6.6.0...6.7.0) - 2022-06-28
## [6.7.1](https://github.com/thephpleague/uri/compare/6.7.0...6.7.1) - 2022-06-29

### Added

- None

### Fixed

- `UriInfo::isCrossOrigin` method is fix to make it work with any PSR-7 compliant object [205](https://github.com/thephpleague/uri/pull/205)

### Deprecated

- None

### Remove

- None

## [6.7.0](https://github.com/thephpleague/uri/compare/6.6.0...6.7.0) - 2022-06-29

### Added

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^v3.3.2",
"nyholm/psr7": "^1.5",
"php-http/psr7-integration-tests": "^1.1",
"phpstan/phpstan": "^1.2.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/UriInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ public static function getOrigin($uri): ?string
*/
public static function isCrossOrigin($uri, $base_uri): bool
{
return null === ($uriString = self::getOrigin($uri))
|| null === ($baseUriString = self::getOrigin($base_uri))
return null === ($uriString = self::getOrigin(Uri::createFromUri($uri)))
|| null === ($baseUriString = self::getOrigin(Uri::createFromUri($base_uri)))
|| $uriString !== $baseUriString;
}
}
2 changes: 2 additions & 0 deletions src/UriInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace League\Uri;

use Nyholm\Psr7\Uri as Psr7Uri;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\UriInterface as Psr7UriInterface;
use TypeError;
Expand Down Expand Up @@ -222,6 +223,7 @@ public function getOriginProvider(): array
public function testIsCrossOrigin(string $original, string $modified, bool $expected): void
{
self::assertSame($expected, UriInfo::isCrossOrigin(Uri::createFromString($original), Http::createFromString($modified)));
self::assertSame($expected, UriInfo::isCrossOrigin(new Psr7Uri($original), new Psr7Uri($modified)));
}

/**
Expand Down

0 comments on commit 2d7c87a

Please sign in to comment.