mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-07 07:43:12 +08:00
Add option to do loosely matches on short URLs when mode is loosely
This commit is contained in:
@@ -9,8 +9,8 @@ use function str_replace;
|
||||
|
||||
class MultiSegmentSlugProcessor
|
||||
{
|
||||
private const SINGLE_SHORT_CODE_PATTERN = '{shortCode}';
|
||||
private const MULTI_SHORT_CODE_PATTERN = '{shortCode:.+}';
|
||||
private const SINGLE_SEGMENT_PATTERN = '{shortCode}';
|
||||
private const MULTI_SEGMENT_PATTERN = '{shortCode:.+}';
|
||||
|
||||
public function __invoke(array $config): array
|
||||
{
|
||||
@@ -21,7 +21,7 @@ class MultiSegmentSlugProcessor
|
||||
|
||||
$config['routes'] = map($config['routes'] ?? [], static function (array $route): array {
|
||||
['path' => $path] = $route;
|
||||
$route['path'] = str_replace(self::SINGLE_SHORT_CODE_PATTERN, self::MULTI_SHORT_CODE_PATTERN, $path);
|
||||
$route['path'] = str_replace(self::SINGLE_SEGMENT_PATTERN, self::MULTI_SEGMENT_PATTERN, $path);
|
||||
return $route;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user