From 1795b21df054f3e843f04065d4e2cec5395fbeb2 Mon Sep 17 00:00:00 2001 From: Colin Richardson Date: Sun, 2 Mar 2014 14:43:44 +0000 Subject: [PATCH] Remove redundant underscore and update the comment --- model/URLSegmentFilter.php | 2 +- tests/model/URLSegmentFilterTest.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/model/URLSegmentFilter.php b/model/URLSegmentFilter.php index 83c5fa36361..9db39725d7e 100644 --- a/model/URLSegmentFilter.php +++ b/model/URLSegmentFilter.php @@ -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 ); /** diff --git a/tests/model/URLSegmentFilterTest.php b/tests/model/URLSegmentFilterTest.php index 44e8a69ea77..74ef7009477 100644 --- a/tests/model/URLSegmentFilterTest.php +++ b/tests/model/URLSegmentFilterTest.php @@ -77,4 +77,9 @@ public function testReplacesDots() { $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')); + } + }