mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2905 from feejin/urlsegment-leading-dashes
Fix: remove all leading dashes from URLSegments
This commit is contained in:
commit
f543041b9c
@ -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
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -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'));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user