diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-23 13:28:02 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-10-27 20:11:30 +0100 |
commit | 34c8f558e595d4f90e46e3753c8455b0b515771a (patch) | |
tree | 5419a51d724a3ce9a22981cabadd6d0dab44e7fb | |
parent | 6a716758871885e5bd045d1981f890dbf3343b1d (diff) | |
download | Shaarli-34c8f558e595d4f90e46e3753c8455b0b515771a.tar.gz Shaarli-34c8f558e595d4f90e46e3753c8455b0b515771a.tar.zst Shaarli-34c8f558e595d4f90e46e3753c8455b0b515771a.zip |
Bulk creation: ignore blank lines
-rw-r--r-- | application/front/controller/admin/ShaarePublishController.php | 3 | ||||
-rw-r--r-- | tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/application/front/controller/admin/ShaarePublishController.php b/application/front/controller/admin/ShaarePublishController.php index 65fdcdee..ddcffdc7 100644 --- a/application/front/controller/admin/ShaarePublishController.php +++ b/application/front/controller/admin/ShaarePublishController.php | |||
@@ -46,6 +46,9 @@ class ShaarePublishController extends ShaarliAdminController | |||
46 | 46 | ||
47 | $links = []; | 47 | $links = []; |
48 | foreach ($urls as $url) { | 48 | foreach ($urls as $url) { |
49 | if (empty($url)) { | ||
50 | continue; | ||
51 | } | ||
49 | $link = $this->buildLinkDataFromUrl($request, $url); | 52 | $link = $this->buildLinkDataFromUrl($request, $url); |
50 | $data = $this->buildFormData($link, $link['linkIsNew'], $request); | 53 | $data = $this->buildFormData($link, $link['linkIsNew'], $request); |
51 | $data['token'] = $this->container->sessionManager->generateToken(); | 54 | $data['token'] = $this->container->sessionManager->generateToken(); |
diff --git a/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php b/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php index 34547120..ce8e112b 100644 --- a/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php +++ b/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php | |||
@@ -36,6 +36,7 @@ class DisplayCreateBatchFormTest extends TestCase | |||
36 | $urls = [ | 36 | $urls = [ |
37 | 'https://domain1.tld/url1', | 37 | 'https://domain1.tld/url1', |
38 | 'https://domain2.tld/url2', | 38 | 'https://domain2.tld/url2', |
39 | ' ', | ||
39 | 'https://domain3.tld/url3', | 40 | 'https://domain3.tld/url3', |
40 | ]; | 41 | ]; |
41 | 42 | ||
@@ -57,6 +58,6 @@ class DisplayCreateBatchFormTest extends TestCase | |||
57 | static::assertCount(3, $assignedVariables['links']); | 58 | static::assertCount(3, $assignedVariables['links']); |
58 | static::assertSame($urls[0], $assignedVariables['links'][0]['link']['url']); | 59 | static::assertSame($urls[0], $assignedVariables['links'][0]['link']['url']); |
59 | static::assertSame($urls[1], $assignedVariables['links'][1]['link']['url']); | 60 | static::assertSame($urls[1], $assignedVariables['links'][1]['link']['url']); |
60 | static::assertSame($urls[2], $assignedVariables['links'][2]['link']['url']); | 61 | static::assertSame($urls[3], $assignedVariables['links'][2]['link']['url']); |
61 | } | 62 | } |
62 | } | 63 | } |