Merge pull request #2905 from feejin/urlsegment-leading-dashes

Fix: remove all leading dashes from URLSegments
This commit is contained in:
Damian Mooyman 2014-03-03 09:56:47 +13:00
commit f543041b9c
2 changed files with 6 additions and 1 deletions

View File

@ -33,7 +33,7 @@ class URLSegmentFilter extends Object {
'/[_.]+/u' => '-', // underscores and dots to dashes
'/[^A-Za-z0-9\-]+/u' => '', // remove non-ASCII chars, only allow alphanumeric and dashes
'/[\-]{2,}/u' => '-', // remove duplicate dashes
'/^[\-_]/u' => '', // Remove all leading dashes or underscores
'/^[\-]+/u' => '' // Remove all leading dashes
);
/**

View File

@ -77,4 +77,9 @@ class URLSegmentFilterTest extends SapphireTest {
$this->assertEquals('url-contains-dot', $filter->filter('url-contains.dot'));
}
public function testRemoveLeadingDashes() {
$filter = new URLSegmentFilter();
$this->assertEquals('url-has-leading-dashes', $filter->filter('---url-has-leading-dashes'));
}
}