Skip to content

Commit

Permalink
Fix: #5053 - wrong canonical formatting for PLAC:FORM
Browse files Browse the repository at this point in the history
  • Loading branch information
fisharebest committed Nov 29, 2024
1 parent bda3570 commit ca7e3cf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Elements/PlaceHierarchy.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PlaceHierarchy extends AbstractElement
public function canonical(string $value): string
{
$value = parent::canonical($value);
$value = preg_replace('/[, ]+/', ', ', $value);
$value = preg_replace('/[, ]*,[, ]*/', ', ', $value);

return trim($value, ', ');
}
Expand Down
4 changes: 1 addition & 3 deletions tests/app/Elements/PlaceHierarchyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ public static function setupBeforeClass(): void

public function testCanonical(): void
{
self::assertSame('Foo, bAr, baZ', self::$element->canonical('Foo bAr baZ'));
self::assertSame('Foo, bAr, baZ', self::$element->canonical("\t Foo\t bAr \tbaZ\t "));
self::assertSame('Foo, bAr, baZ', self::$element->canonical("\nFoo \n\r bAr \r\n baZ\r"));
self::assertSame('Foo, Bar, Baz', self::$element->canonical(',,Foo,Bar , , Baz, '));
self::assertSame('City State, Country or Territory', self::$element->canonical(' City State,, Country or Territory,'));
}
}

0 comments on commit ca7e3cf

Please sign in to comment.