Skip to content

Commit

Permalink
Backport fix to v2 branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyamcl committed Aug 20, 2020
1 parent 700582d commit 68fd06c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Expand Up @@ -15,12 +15,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed bug from v2.3: If default slugifier is used (UniqueSlugify.php), then ensure unique instance each time `MarkupFixer::fix()` is run
This will prevent it from continuing to generate unique slugs if used more than once.

## [2.3.1] - 2020-08-20
### Fixed
- Backport: Fixed bug from v2.3: If default slugifier is used (UniqueSluggifier.php), then ensure unique instance each time `MarkupFixer::fix()` is run
This will prevent it from continuing to generate unique slugs if used more than once.

## [2.3] - 2020-07-16
### Added
- Ability to inject the slugify class (#26) (thanks @yaquawa)

### Changed
- Renamed internal class `UniqueSluggifier` to `UniqueSlugify`
- ~~Renamed internal class `UniqueSluggifier` to `UniqueSlugify`~~

## [2.2] - 2020-04-12
### Changed
Expand Down
4 changes: 2 additions & 2 deletions src/MarkupFixer.php
Expand Up @@ -53,7 +53,7 @@ class MarkupFixer
public function __construct(?HTML5 $htmlParser = null, ?SlugifyInterface $slugify = null)
{
$this->htmlParser = $htmlParser ?? new HTML5();
$this->sluggifier = $slugify ?? new UniqueSlugify();
$this->sluggifier = $slugify ?? new UniqueSluggifier();
}

/**
Expand All @@ -76,7 +76,7 @@ public function fix(string $markup, int $topLevel = 1, int $depth = 6): string
$domDocument->preserveWhiteSpace = true; // do not clobber whitespace

// If using the default slugifier, ensure that a unique instance of the class
$slugger = $this->sluggifier instanceof UniqueSlugify ? new UniqueSlugify() : $this->sluggifier;
$slugger = $this->sluggifier instanceof UniqueSluggifier ? new UniqueSluggifier() : $this->sluggifier;

/** @var DOMElement $node */
foreach ($this->traverseHeaderTags($domDocument, $topLevel, $depth) as $node) {
Expand Down
2 changes: 1 addition & 1 deletion src/UniqueSlugify.php → src/UniqueSluggifier.php
Expand Up @@ -28,7 +28,7 @@
*
* @author Casey McLaughlin <caseyamcl@gmail.com>
*/
class UniqueSlugify implements SlugifyInterface
class UniqueSluggifier implements SlugifyInterface
{
/**
* @var Slugify
Expand Down

0 comments on commit 68fd06c

Please sign in to comment.