aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/http/HttpUtils.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-10-22 16:21:03 +0200
committerArthurHoaro <arthur@hoa.ro>2020-11-05 17:54:42 +0100
commitb3bd8c3e8d367975980043e772f7cd78b7f96bc6 (patch)
treeec79899ea564c093d8b0578f3e614881a4ea7c3d /application/http/HttpUtils.php
parent48df9f45b8c4b2995c1e04146071628668531b37 (diff)
downloadShaarli-b3bd8c3e8d367975980043e772f7cd78b7f96bc6.tar.gz
Shaarli-b3bd8c3e8d367975980043e772f7cd78b7f96bc6.tar.zst
Shaarli-b3bd8c3e8d367975980043e772f7cd78b7f96bc6.zip
Feature: support any tag separator
So it allows to have multiple words tags. Breaking change: commas ',' are no longer a default separator. Fixes #594
Diffstat (limited to 'application/http/HttpUtils.php')
-rw-r--r--application/http/HttpUtils.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/application/http/HttpUtils.php b/application/http/HttpUtils.php
index 28c12969..ed1002b0 100644
--- a/application/http/HttpUtils.php
+++ b/application/http/HttpUtils.php
@@ -550,7 +550,8 @@ function get_curl_download_callback(
550 &$title, 550 &$title,
551 &$description, 551 &$description,
552 &$keywords, 552 &$keywords,
553 $retrieveDescription 553 $retrieveDescription,
554 $tagsSeparator
554) { 555) {
555 $currentChunk = 0; 556 $currentChunk = 0;
556 $foundChunk = null; 557 $foundChunk = null;
@@ -568,6 +569,7 @@ function get_curl_download_callback(
568 */ 569 */
569 return function ($ch, $data) use ( 570 return function ($ch, $data) use (
570 $retrieveDescription, 571 $retrieveDescription,
572 $tagsSeparator,
571 &$charset, 573 &$charset,
572 &$title, 574 &$title,
573 &$description, 575 &$description,
@@ -598,10 +600,10 @@ function get_curl_download_callback(
598 if (! empty($keywords)) { 600 if (! empty($keywords)) {
599 $foundChunk = $currentChunk; 601 $foundChunk = $currentChunk;
600 // Keywords use the format tag1, tag2 multiple words, tag 602 // Keywords use the format tag1, tag2 multiple words, tag
601 // So we format them to match Shaarli's separator and glue multiple words with '-' 603 // So we split the result with `,`, then if a tag contains the separator we replace it by `-`.
602 $keywords = implode(' ', array_map(function($keyword) { 604 $keywords = tags_array2str(array_map(function(string $keyword) use ($tagsSeparator): string {
603 return implode('-', preg_split('/\s+/', trim($keyword))); 605 return tags_array2str(tags_str2array($keyword, $tagsSeparator), '-');
604 }, explode(',', $keywords))); 606 }, tags_str2array($keywords, ',')), $tagsSeparator);
605 } 607 }
606 } 608 }
607 609