fix: ignore attempts to look for versions of rfcs, but find the rfc.

This commit is contained in:
Robert Sparks 2023-12-13 11:54:22 -06:00
parent 18a8b3dfc7
commit d74d5ed233
No known key found for this signature in database
GPG key ID: 6E2A6A5775F91318
2 changed files with 10 additions and 3 deletions

View file

@ -309,6 +309,12 @@ class MiscTests(TestCase):
found = fuzzy_find_documents(draft.name, '22')
self.assertCountEqual(found.documents, [draft],
'Should find document even if rev does not exist')
# by rfc name mistakenly trying to provide a revision
found = fuzzy_find_documents(rfc.name+"-22")
self.assertCountEqual(found.documents, [rfc], "Should ignore versions when fuzzyfinding RFCs" )
found = fuzzy_find_documents(rfc.name,"22")
self.assertCountEqual(found.documents, [rfc], "Should ignore versions when fuzzyfinding RFCs" )
def test_fuzzy_find_documents(self):

View file

@ -1209,14 +1209,15 @@ def fuzzy_find_documents(name, rev=None):
if name.startswith("rfc"):
sought_type = "rfc"
log.assertion("rev is None")
name = name.split("-")[0] # strip any noise (like a revision) at and after the first hyphen
rev = None # If someone is looking for an RFC and supplies a version, ignore it.
else:
sought_type = "draft"
# see if we can find a document using this name
docs = Document.objects.filter(name=name, type_id=sought_type)
if rev and not docs.exists():
# No document found, see if the name/rev split has been misidentified.
if sought_type == "draft" and rev and not docs.exists():
# No draft found, see if the name/rev split has been misidentified.
# Handles some special cases, like draft-ietf-tsvwg-ieee-802-11.
name = '%s-%s' % (name, rev)
docs = Document.objects.filter(name=name, type_id='draft')