about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2025-07-08 14:32:45 +0900
committerNguyễn Gia Phong <cnx@loang.net>2025-07-08 15:07:48 +0900
commite638ca3f5062f592e796fae33391fb715dbf0c9e (patch)
treeeeafa54da1f26816085bc1770cd97b4459fdc005
parenta8dc08a11182632ad6fb93af95958c95a09195bd (diff)
downloadscadere-e638ca3f5062f592e796fae33391fb715dbf0c9e.tar.gz
Include queries in atom:id and atom:link[@rel=self]
-rw-r--r--src/scadere/__init__.py2
-rw-r--r--src/scadere/listen.py13
-rw-r--r--tst/test_listen.py3
3 files changed, 10 insertions, 8 deletions
diff --git a/src/scadere/__init__.py b/src/scadere/__init__.py
index baf79cf..82c884a 100644
--- a/src/scadere/__init__.py
+++ b/src/scadere/__init__.py
@@ -8,7 +8,7 @@ from importlib.resources import files
 
 __all__ = ['__version__', 'GNUHelpFormatter', 'NetLoc',
            'atom2xhtml', 'format_epilog', 'format_version']
-__version__ = '0.2.2'
+__version__ = '0.2.3'
 
 EXAMPLE_PREFIX = ' ' * 2
 # help2man's implementation detail
diff --git a/src/scadere/listen.py b/src/scadere/listen.py
index 3cb6bb7..dc6230e 100644
--- a/src/scadere/listen.py
+++ b/src/scadere/listen.py
@@ -144,11 +144,13 @@ def is_subdomain(subject, objects):
                for obj_parts in map(split_domain, objects))
 
 
-def feed(base_url, name, mtime, certificates, domains):
+def feed(base_url, query, name, mtime, certificates):
     """Construct an Atom feed based on the given information."""
+    url = f'{base_url}?{query}'
+    domains = tuple(parse_qs(query).get('domain', []))
     return ('feed', {'xmlns': 'http://www.w3.org/2005/Atom'},
-            ('id', base_url),
-            ('link', {'rel': 'self', 'href': base_url}),
+            ('id', url),
+            ('link', {'rel': 'self', 'href': url}),
             ('title', name),
             ('updated', mtime),
             ('generator',
@@ -287,7 +289,6 @@ async def handle(certs, base_url, reader, writer, title=''):
             lookup = dict(map(tuple, zip(paths, summaries)))
             assert len(lookup) == len(summaries)
             url_parts = urlsplit(urljoin(base_url, url.strip().decode()))
-            domains = tuple(parse_qs(url_parts.query).get('domain', []))
         except Exception:  # pragma: no cover
             describe_status(writer, HTTPStatus.INTERNAL_SERVER_ERROR,
                             http_version)
@@ -295,8 +296,8 @@ async def handle(certs, base_url, reader, writer, title=''):
 
         if url_parts.path == urlsplit(base_url).path:  # Atom feed
             write_xml(writer, http_version, 'atom', unparsed_feed,
-                      base_url, title or certs.name, mtime, summaries, domains,
-                      mtime=mtime)
+                      base_url, url_parts.query, title or certs.name,
+                      mtime, summaries, mtime=mtime)
         elif url_parts.path == urlsplit(atom2xhtml_url(base_url)).path:
             write_xml(writer, http_version, 'xslt', atom2xhtml)
         elif url_parts.path in lookup:  # accessible Atom entry's link/ID
diff --git a/tst/test_listen.py b/tst/test_listen.py
index 85c13f9..bf677e2 100644
--- a/tst/test_listen.py
+++ b/tst/test_listen.py
@@ -16,7 +16,7 @@ from urllib.parse import urljoin, urlsplit
 from xml.etree.ElementTree import (XML, XMLParser, indent,
                                    tostring as str_from_xml)
 
-from hypothesis import HealthCheck, given, settings
+from hypothesis import HealthCheck, example, given, settings
 from hypothesis.strategies import (booleans, composite, data,
                                    datetimes, from_type, integers, just,
                                    sampled_from, sets, text, uuids)
@@ -57,6 +57,7 @@ def test_path(hostname, port, number, string):
     assert str_from_base64(r[2]) == string
 
 
+@example('example.net', {'net'})
 @given(domains(), sets(domains()))
 def test_is_subdomain(subject, objects):
     if not objects: