diff --git a/pywb/cdx/cdxops.py b/pywb/cdx/cdxops.py index 4074ee29..dfae8b18 100644 --- a/pywb/cdx/cdxops.py +++ b/pywb/cdx/cdxops.py @@ -122,6 +122,8 @@ def cdx_reverse(cdx_iter, limit): for cdx in cdx_iter: last = cdx + if not last: + return yield last reverse_cdxs = deque(maxlen=limit) diff --git a/pywb/cdx/test/cdxserver_test.py b/pywb/cdx/test/cdxserver_test.py index bfb29d1f..76282ed2 100644 --- a/pywb/cdx/test/cdxserver_test.py +++ b/pywb/cdx/test/cdxserver_test.py @@ -28,6 +28,10 @@ org,iana)/_js/2013.1/jquery.js 20140126201307 https://www.iana.org/_js/2013.1/jq Traceback (most recent call last): CaptureNotFoundException: No Captures found for: http://iana.org/dont_have_this +# No matching -- limit=1 +>>> cdx_ops_test('http://iana.org/dont_have_this', reverse = True, resolveRevisits = True, limit = 1) +Traceback (most recent call last): +CaptureNotFoundException: No Captures found for: http://iana.org/dont_have_this # Filter cdx (default: regex) >>> cdx_ops_test(url = 'http://iana.org/domains', matchType = 'prefix', filter = ['mimetype:text/html']) diff --git a/pywb/cdx/test/test_lazy_ops.py b/pywb/cdx/test/test_lazy_ops.py index 3a319203..fa579d0d 100644 --- a/pywb/cdx/test/test_lazy_ops.py +++ b/pywb/cdx/test/test_lazy_ops.py @@ -45,6 +45,9 @@ def test_closest(): def test_limit(): lazy_cdx_load(key=KEY, limit=10) +def test_limit_1_reverse(): + lazy_cdx_load(key=KEY, limit=1, reverse=True) + def test_multi_ops(): lazy_cdx_load(key=KEY, resolveRevisits=True,