You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stormcrawler.apache.org by rz...@apache.org on 2025/08/18 18:17:08 UTC
(stormcrawler) 01/02: chore: remove magic number from filterPathRepeat method
This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/stormcrawler.git
commit 5a1629fa9284f11590247c613e04478319b03047
Author: Tamim Ehsan <ta...@gmail.com>
AuthorDate: Sat Aug 16 13:00:35 2025 +0800
chore: remove magic number from filterPathRepeat method
---
.../org/apache/stormcrawler/filtering/basic/BasicURLFilter.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/core/src/main/java/org/apache/stormcrawler/filtering/basic/BasicURLFilter.java b/core/src/main/java/org/apache/stormcrawler/filtering/basic/BasicURLFilter.java
index d7acf0a2..1e51191c 100644
--- a/core/src/main/java/org/apache/stormcrawler/filtering/basic/BasicURLFilter.java
+++ b/core/src/main/java/org/apache/stormcrawler/filtering/basic/BasicURLFilter.java
@@ -48,7 +48,11 @@ public class BasicURLFilter extends URLFilter {
public final String filterPathRepeat(String urlToFilter) {
// check whether a path element is repeated N times
String[] paths = urlToFilter.split("/");
- if (paths.length <= 4) return urlToFilter;
+
+ final int minimumPathLength = 5;
+ // e.g. http://www.example.com/path/path will need 5 parts to have a repetition
+
+ if (paths.length < minimumPathLength) return urlToFilter;
Map<String, Integer> count = new HashMap<>();
for (String s : paths) {