Skip to content

Commit

Permalink
Really fixes microformats#159 - make types unique
Browse files Browse the repository at this point in the history
  • Loading branch information
Zegnat committed Mar 25, 2018
1 parent 5eeef8b commit 0ce2eda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Mf2/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,8 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
}
}

// Make sure things are in alphabetical order
// Make sure things are unique and in alphabetical order
$mfTypes = array_unique($mfTypes);
sort($mfTypes);

// Phew. Return the final result.
Expand Down
10 changes: 10 additions & 0 deletions tests/Mf2/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -766,5 +766,15 @@ public function testMfClassRegex() {
$this->assertArrayHasKey('123-url', $output['items'][0]['properties']);
}

/**
* @see https://github.com/microformats/microformats2-parsing/issues/30
*/
public function testUniqueAndAlphabeticalMfClasses() {
$input = '<div class="h-entry h-cite h-entry"></div>';
$output = Mf2\parse($input);

$this->assertEquals(array('h-cite', 'h-entry'), $output['items'][0]['type']);
}

}

0 comments on commit 0ce2eda

Please # to comment.