Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ietf/doc/tests_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ def do_fuzzy_find_documents_rfc_test(self, name):
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):
Expand Down
7 changes: 4 additions & 3 deletions ietf/doc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down