From ce9bdc9ad9429bfc42d060190f342440d71c8cc6 Mon Sep 17 00:00:00 2001 From: Chihchy Date: Fri, 8 Sep 2023 12:29:17 +0800 Subject: [PATCH] Fix page range filter logics --- EhPanda/App/Tools/Utilities/URLUtil.swift | 28 ++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/EhPanda/App/Tools/Utilities/URLUtil.swift b/EhPanda/App/Tools/Utilities/URLUtil.swift index 82b618a1..583529f5 100644 --- a/EhPanda/App/Tools/Utilities/URLUtil.swift +++ b/EhPanda/App/Tools/Utilities/URLUtil.swift @@ -177,13 +177,29 @@ private extension URL { queryItems1[.fSrdd] = String(filter.minRating) } - if filter.pageRangeActivated, let minPages = Int(filter.pageLowerBound), - let maxPages = Int(filter.pageUpperBound), - minPages > 0 && maxPages > 0 && minPages <= maxPages - { + if filter.pageRangeActivated { queryItems2[.fSp] = .filterOn - queryItems1[.fSpf] = String(minPages) - queryItems1[.fSpt] = String(maxPages) + + switch (Int(filter.pageLowerBound), Int(filter.pageUpperBound)) { + case let (.some(minPages), .some(maxPages)): + if minPages > 0 && maxPages > 0 && minPages <= maxPages { + queryItems1[.fSpf] = String(minPages) + queryItems1[.fSpt] = String(maxPages) + } + + case let (.some(minPages), _): + if minPages > 0 { + queryItems1[.fSpf] = String(minPages) + } + + case let (_, .some(maxPages)): + if maxPages > 0 { + queryItems1[.fSpt] = String(maxPages) + } + + case (.none, .none): + break + } } if filter.disableLanguage { queryItems2[.fSfl] = .filterOn }