]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Bulk creation: ignore blank lines 1587/head
authorArthurHoaro <arthur@hoa.ro>
Fri, 23 Oct 2020 11:28:02 +0000 (13:28 +0200)
committerArthurHoaro <arthur@hoa.ro>
Tue, 27 Oct 2020 19:11:30 +0000 (20:11 +0100)
application/front/controller/admin/ShaarePublishController.php
tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php

index 65fdcdee79bc5f27561e35529f68adbb0f2f6e64..ddcffdc77a4c21e8fb5c7d050ce03cc0137d7ff5 100644 (file)
@@ -46,6 +46,9 @@ class ShaarePublishController extends ShaarliAdminController
 
         $links = [];
         foreach ($urls as $url) {
+            if (empty($url)) {
+                continue;
+            }
             $link = $this->buildLinkDataFromUrl($request, $url);
             $data = $this->buildFormData($link, $link['linkIsNew'], $request);
             $data['token'] = $this->container->sessionManager->generateToken();
index 34547120a6497da8198e60209c0a616fcb4a9f26..ce8e112b6204829571d5dec3079808fd311d180a 100644 (file)
@@ -36,6 +36,7 @@ class DisplayCreateBatchFormTest extends TestCase
         $urls = [
             'https://domain1.tld/url1',
             'https://domain2.tld/url2',
+            ' ',
             'https://domain3.tld/url3',
         ];
 
@@ -57,6 +58,6 @@ class DisplayCreateBatchFormTest extends TestCase
         static::assertCount(3, $assignedVariables['links']);
         static::assertSame($urls[0], $assignedVariables['links'][0]['link']['url']);
         static::assertSame($urls[1], $assignedVariables['links'][1]['link']['url']);
-        static::assertSame($urls[2], $assignedVariables['links'][2]['link']['url']);
+        static::assertSame($urls[3], $assignedVariables['links'][2]['link']['url']);
     }
 }