PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: lektor/lektor (python)

Issue:
Bug: `build_url` may remove trailing slash
Found this by browsing through the source. Havent tested whether this is actually an issue, but:

https://github.com/lektor/lektor/blob/dbae91e9c767093349b122f62e114e32e8291f85/lektor/utils.py#L666-L668

shouldn't that actually be
```py
last = url.split("/")[-1]
# or:
# if "." in url.split("/")[-1]:
```

Otherwise, an URL like this `/path.my/page/2/` may wrongly remove the trailing slash.

Pull request:
fix: Fix bug in url generation
### Issue(s) Resolved

Fixes #1080

### Related Issues / Links

### Description of Changes

- [x] Added unit test(s) covering the changes (if testable)

I've fixed a small error with url handling and added a realistic test case.

Patch:
diff --git a/lektor/utils.py b/lektor/utils.py
index 9cbcd9a..a518f00 100644
--- a/lektor/utils.py
+++ b/lektor/utils.py
@@ -827,8 +827,9 @@ class URLBuilder:
         if url == "/":
             return url
         if trailing_slash is None:
-            _, last = url.split("/", 1)
+            _, last = url.rsplit("/", 1)
             if "." in last:
+                # Assuming the url points to a file
                 return url
         return url + "/"
 


Test patch:
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 04ea966..7338804 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -197,6 +197,10 @@ def test_url_builder():
     assert build_url(["a", None, "b", "", "c"]) == "/a/b/c/"
 
 
+def test_url_builder_dot_handling():
+    assert build_url(["blog", "01.01.2025", "photos"]) == "/blog/01.01.2025/photos/"
+
+
 def test_parse_path():
     assert parse_path("") == []
     assert parse_path("/") == []