-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Flowpack/8-feature-enforce-no-trailing-slash
TASK: add option to remove trailing slashes
- Loading branch information
Showing
11 changed files
with
166 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Flowpack\SeoRouting\Enum; | ||
|
||
enum TrailingSlashModeEnum: string | ||
{ | ||
case ADD = 'add'; | ||
case REMOVE = 'remove'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,18 +13,26 @@ | |
#[CoversClass(TrailingSlashHelper::class)] | ||
class TrailingSlashHelperTest extends TestCase | ||
{ | ||
#[DataProvider('urlDataProvider')] | ||
#[DataProvider('urlDataProviderForAppendTrailingSlash')] | ||
public function testAppendTrailingSlash(string $input, string $output): void | ||
{ | ||
$uri = new Uri($input); | ||
|
||
self::assertSame($output, (string)(new TrailingSlashHelper())->appendTrailingSlash($uri)); | ||
} | ||
|
||
#[DataProvider('urlDataProviderForRemoveTrailingSlash')] | ||
public function testRemoveTrailingSlash(string $input, string $output): void | ||
{ | ||
$uri = new Uri($input); | ||
|
||
self::assertSame($output, (string)(new TrailingSlashHelper())->removeTrailingSlash($uri)); | ||
} | ||
|
||
/** | ||
* @return array{string[]} | ||
*/ | ||
public static function urlDataProvider(): array | ||
public static function urlDataProviderForAppendTrailingSlash(): array | ||
{ | ||
return [ | ||
['', ''], | ||
|
@@ -47,4 +55,31 @@ public static function urlDataProvider(): array | |
['https://test.de/foo/bar.css', 'https://test.de/foo/bar.css'], | ||
]; | ||
} | ||
|
||
/** | ||
* @return array{string[]} | ||
*/ | ||
public static function urlDataProviderForRemoveTrailingSlash(): array | ||
{ | ||
return [ | ||
['', ''], | ||
['/', ''], | ||
['/foo/', '/foo'], | ||
['/foo/bar/', '/foo/bar'], | ||
['https://test.de', 'https://test.de'], | ||
['https://test.de', 'https://test.de'], | ||
['https://test.de/foo/bar/', 'https://test.de/foo/bar'], | ||
['https://test.de/foo/bar', 'https://test.de/foo/bar'], | ||
['/foo/bar/?some-query=foo%20bar', '/foo/bar?some-query=foo%20bar'], | ||
['/foo/bar/#some-fragment', '/foo/bar#some-fragment'], | ||
['/foo/bar/?some-query=foo%20bar#some-fragment', '/foo/bar?some-query=foo%20bar#some-fragment'], | ||
[ | ||
'https://test.de/foo/bar/?some-query=foo%20bar#some-fragment', | ||
'https://test.de/foo/bar?some-query=foo%20bar#some-fragment', | ||
], | ||
['mailto:[email protected]', 'mailto:[email protected]'], | ||
['tel:+4906516564', 'tel:+4906516564'], | ||
['https://test.de/foo/bar.css', 'https://test.de/foo/bar.css'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.