mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 15:13:59 -06:00
Fixed duplicated slashes generated in path when doing not-found redirects with placeholders
This commit is contained in:
parent
77fee1390f
commit
492eba3a8b
@ -70,7 +70,10 @@ class NotFoundRedirectResolver implements NotFoundRedirectResolverInterface
|
|||||||
$replacePlaceholderForPattern(self::DOMAIN_PLACEHOLDER, $domain, $modifier),
|
$replacePlaceholderForPattern(self::DOMAIN_PLACEHOLDER, $domain, $modifier),
|
||||||
$replacePlaceholderForPattern(self::ORIGINAL_PATH_PLACEHOLDER, $path, $modifier),
|
$replacePlaceholderForPattern(self::ORIGINAL_PATH_PLACEHOLDER, $path, $modifier),
|
||||||
);
|
);
|
||||||
$replacePlaceholdersInPath = $replacePlaceholders('\Functional\id');
|
$replacePlaceholdersInPath = compose(
|
||||||
|
$replacePlaceholders('\Functional\id'),
|
||||||
|
static fn (?string $path) => $path === null ? null : str_replace('//', '/', $path), // Fix duplicated bars
|
||||||
|
);
|
||||||
$replacePlaceholdersInQuery = $replacePlaceholders('\urlencode');
|
$replacePlaceholdersInQuery = $replacePlaceholders('\urlencode');
|
||||||
|
|
||||||
return $redirectUri
|
return $redirectUri
|
||||||
|
@ -99,7 +99,7 @@ class NotFoundRedirectResolverTest extends TestCase
|
|||||||
new NotFoundRedirectOptions([
|
new NotFoundRedirectOptions([
|
||||||
'regular404' => 'https://redirect-here.com/{ORIGINAL_PATH}/{DOMAIN}/?d={DOMAIN}&p={ORIGINAL_PATH}',
|
'regular404' => 'https://redirect-here.com/{ORIGINAL_PATH}/{DOMAIN}/?d={DOMAIN}&p={ORIGINAL_PATH}',
|
||||||
]),
|
]),
|
||||||
'https://redirect-here.com//foo/bar/doma.in/?d=doma.in&p=%2Ffoo%2Fbar', // TODO Fix duplicated slash
|
'https://redirect-here.com/foo/bar/doma.in/?d=doma.in&p=%2Ffoo%2Fbar',
|
||||||
];
|
];
|
||||||
yield 'invalid short URL' => [
|
yield 'invalid short URL' => [
|
||||||
new Uri('/foo'),
|
new Uri('/foo'),
|
||||||
@ -111,7 +111,7 @@ class NotFoundRedirectResolverTest extends TestCase
|
|||||||
new Uri('/foo'),
|
new Uri('/foo'),
|
||||||
$this->notFoundType($this->requestForRoute(RedirectAction::class)),
|
$this->notFoundType($this->requestForRoute(RedirectAction::class)),
|
||||||
new NotFoundRedirectOptions(['invalidShortUrl' => 'https://redirect-here.com/{ORIGINAL_PATH}']),
|
new NotFoundRedirectOptions(['invalidShortUrl' => 'https://redirect-here.com/{ORIGINAL_PATH}']),
|
||||||
'https://redirect-here.com//foo', // TODO Fix duplicated slash
|
'https://redirect-here.com/foo',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user