Skip to content

Commit cf53cfd

Browse files
authored
Merge pull request #166 from Zegnat/hot-fix-types-array
Really fixes #159 - make types unique
2 parents 5eeef8b + 0ce2eda commit cf53cfd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Mf2/Parser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,8 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
11661166
}
11671167
}
11681168

1169-
// Make sure things are in alphabetical order
1169+
// Make sure things are unique and in alphabetical order
1170+
$mfTypes = array_unique($mfTypes);
11701171
sort($mfTypes);
11711172

11721173
// Phew. Return the final result.

tests/Mf2/ParserTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,5 +766,15 @@ public function testMfClassRegex() {
766766
$this->assertArrayHasKey('123-url', $output['items'][0]['properties']);
767767
}
768768

769+
/**
770+
* @see https://github.com/microformats/microformats2-parsing/issues/30
771+
*/
772+
public function testUniqueAndAlphabeticalMfClasses() {
773+
$input = '<div class="h-entry h-cite h-entry"></div>';
774+
$output = Mf2\parse($input);
775+
776+
$this->assertEquals(array('h-cite', 'h-entry'), $output['items'][0]['type']);
777+
}
778+
769779
}
770780

0 commit comments

Comments
 (0)