From 8ff913aaf239bcacc5f8b0a8b7e0f6f062d4e26e Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 2 Feb 2020 20:07:19 +0100 Subject: [PATCH 1/3] Ensured search terms are applied to the domain too --- module/Core/src/Repository/ShortUrlRepository.php | 14 ++++++++------ module/Rest/test-api/Action/ListShortUrlsTest.php | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/module/Core/src/Repository/ShortUrlRepository.php b/module/Core/src/Repository/ShortUrlRepository.php index a9d21952..31fe1385 100644 --- a/module/Core/src/Repository/ShortUrlRepository.php +++ b/module/Core/src/Repository/ShortUrlRepository.php @@ -110,12 +110,14 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI } // Apply search conditions - $qb->andWhere($qb->expr()->orX( - $qb->expr()->like('s.longUrl', ':searchPattern'), - $qb->expr()->like('s.shortCode', ':searchPattern'), - $qb->expr()->like('t.name', ':searchPattern'), - )); - $qb->setParameter('searchPattern', '%' . $searchTerm . '%'); + $qb->leftJoin('s.domain', 'd') + ->andWhere($qb->expr()->orX( + $qb->expr()->like('s.longUrl', ':searchPattern'), + $qb->expr()->like('s.shortCode', ':searchPattern'), + $qb->expr()->like('t.name', ':searchPattern'), + $qb->expr()->like('d.authority', ':searchPattern'), + )) + ->setParameter('searchPattern', '%' . $searchTerm . '%'); } // Filter by tags if provided diff --git a/module/Rest/test-api/Action/ListShortUrlsTest.php b/module/Rest/test-api/Action/ListShortUrlsTest.php index 7af30948..7d4e51a7 100644 --- a/module/Rest/test-api/Action/ListShortUrlsTest.php +++ b/module/Rest/test-api/Action/ListShortUrlsTest.php @@ -169,6 +169,9 @@ class ListShortUrlsTest extends ApiTestCase self::SHORT_URL_META, self::SHORT_URL_CUSTOM_DOMAIN, ]]; + yield [['searchTerm' => 'example.com'], [ + self::SHORT_URL_CUSTOM_DOMAIN, + ]]; } private function buildPagination(int $itemsCount): array From 8d8a0f2484d08a21b1c7e152dd8f41767e93df7f Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 2 Feb 2020 20:08:22 +0100 Subject: [PATCH 2/3] Updated changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bdbbabf..31fc0890 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased] +## 2.0.3 - 2020-02-02 #### Added @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * [#620](https://github.com/shlinkio/shlink/issues/620) Ensured "controlled" errors (like validation errors and such) won't be logged with error level, preventing logs to be polluted. * [#637](https://github.com/shlinkio/shlink/issues/637) Fixed several work flows in which short URLs with domain are handled form the API. * [#644](https://github.com/shlinkio/shlink/issues/644) Fixed visits to short URL on non-default domain being linked to the URL on default domain with the same short code. +* [#643](https://github.com/shlinkio/shlink/issues/643) Fixed searching on short URL lists not taking into consideration the domain name. ## 2.0.3 - 2020-01-27 From 0c0349fa3933326f138f57cfedef4b8ec8f00e13 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 2 Feb 2020 20:09:30 +0100 Subject: [PATCH 3/3] Fixed version on changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31fc0890..947806a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). -## 2.0.3 - 2020-02-02 +## 2.0.4 - 2020-02-02 #### Added