Skip to content

Commit

Permalink
Canonicalizer documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bpolaszek committed Dec 6, 2017
1 parent 417512f commit 7e9966b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ $uri = current_location(LeagueUriAdapter::factory());
$uri = current_location(ZendDiactorosAdapter::factory());
```

## Canonicalizer

This library ships with an URL canonicalizer.

It is not a perfect one since your PSR-7 library may behave differently regarding special chars, but it should work most of the time.

The `canonicalize()` function accepts any PSR-7 `UriInterface` object and will return a canonicalized one.

```php
require_once __DIR__ . '/vendor/autoload.php';

use function BenTools\UriFactory\Helper\canonicalize;
use function BenTools\UriFactory\Helper\uri;

$url = 'http://example.org../foo/../bar/?#baz';
echo canonicalize(uri($url)); // http://example.org/bar/
```


## Installation

PHP 7.1+ is required.
Expand Down

0 comments on commit 7e9966b

Please sign in to comment.