Merge pull request #1624 from ArthurHoaro/fix/delete-redirect

Fix: redirect to referrer after bookmark deletion
This commit is contained in:
ArthurHoaro 2020-11-05 16:36:34 +01:00 committed by GitHub
commit 47d1581850
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -66,8 +66,8 @@ class ShaareManageController extends ShaarliAdminController
return $response->write('<script>self.close();</script>');
}
// Don't redirect to where we were previously because the datastore has changed.
return $this->redirect($response, '/');
// Don't redirect to permalink after deletion.
return $this->redirectFromReferer($request, $response, ['shaare/']);
}
/**

View file

@ -38,6 +38,8 @@ class DeleteBookmarkTest extends TestCase
{
$parameters = ['id' => '123'];
$this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/shaare/abcdef';
$request = $this->createMock(Request::class);
$request
->method('getParam')
@ -90,6 +92,8 @@ class DeleteBookmarkTest extends TestCase
{
$parameters = ['id' => '123 456 789'];
$this->container->environment['HTTP_REFERER'] = 'http://shaarli/subfolder/?searchtags=abcdef';
$request = $this->createMock(Request::class);
$request
->method('getParam')
@ -152,7 +156,7 @@ class DeleteBookmarkTest extends TestCase
$result = $this->controller->deleteBookmark($request, $response);
static::assertSame(302, $result->getStatusCode());
static::assertSame(['/subfolder/'], $result->getHeader('location'));
static::assertSame(['/subfolder/?searchtags=abcdef'], $result->getHeader('location'));
}
/**