-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix sharing to Flus through the PWA
- Loading branch information
1 parent
e247e16
commit ef66025
Showing
8 changed files
with
107 additions
and
17 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace App\controllers; | ||
|
||
use Minz\Request; | ||
use Minz\Response; | ||
|
||
/** | ||
* @author Marien Fressinaud <dev@marienfressinaud.fr> | ||
* @license http://www.gnu.org/licenses/agpl-3.0.en.html AGPL | ||
*/ | ||
class Shares | ||
{ | ||
/** | ||
* Allow to share a URL to Flus. | ||
* | ||
* @request_param string title (ignored) | ||
* @request_param string text | ||
* @request_param string url | ||
* | ||
* @response 302 /links/search?autosubmit=1&url=<url|text> | ||
*/ | ||
public function new(Request $request): Response | ||
{ | ||
$url = $request->param('url', ''); | ||
$text = $request->param('text', ''); | ||
|
||
if ($url === '') { | ||
$url = $text; | ||
} | ||
|
||
return Response::redirect('show search link', [ | ||
'url' => $url, | ||
'autosubmit' => true, | ||
]); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace App\controllers; | ||
|
||
class SharesTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
use \Minz\Tests\ApplicationHelper; | ||
use \Minz\Tests\InitializerHelper; | ||
use \Minz\Tests\ResponseAsserts; | ||
use \tests\FakerHelper; | ||
use \tests\LoginHelper; | ||
|
||
public function testNewRedirectosToLinkSearchWithUrl(): void | ||
{ | ||
$url = 'https://flus.fr'; | ||
|
||
$response = $this->appRun('GET', '/share', [ | ||
'url' => $url, | ||
]); | ||
|
||
$encoded_url = urlencode($url); | ||
$this->assertResponseCode($response, 302, "/links/search?url={$encoded_url}&autosubmit=1"); | ||
} | ||
|
||
public function testNewRedirectosToLinkSearchWithText(): void | ||
{ | ||
$url = 'https://flus.fr'; | ||
|
||
$response = $this->appRun('GET', '/share', [ | ||
'text' => $url, | ||
]); | ||
|
||
$encoded_url = urlencode($url); | ||
$this->assertResponseCode($response, 302, "/links/search?url={$encoded_url}&autosubmit=1"); | ||
} | ||
} |