diff --git a/bibxml/xml2rfc_adapters.py b/bibxml/xml2rfc_adapters.py index 868741c2..426a88ee 100644 --- a/bibxml/xml2rfc_adapters.py +++ b/bibxml/xml2rfc_adapters.py @@ -503,6 +503,23 @@ def resolve_docid(self) -> Optional[DocID]: return None + def resolve(self) -> BibliographicItem: + refs = self.fetch_refs() + if num_refs := len(refs): + self.log(f"{num_refs} found") + resolved_item = self.build_bibitem_from_refs(refs) + link = as_list(resolved_item.link or []) + for index, _ in enumerate(link): + parsed_link = urlparse(link[index].content) + if parsed_link.scheme == "http": + link[index].content = \ + parsed_link._replace(scheme="https").geturl() + return resolved_item + else: + self.log("no refs found") + raise RefNotFoundError() + + @register_adapter('bibxml9') class RfcSubseriesAdapter(Xml2rfcAdapter): """ diff --git a/xml2rfc_compat/tests/test_adapters.py b/xml2rfc_compat/tests/test_adapters.py index 33694803..b02cbe39 100644 --- a/xml2rfc_compat/tests/test_adapters.py +++ b/xml2rfc_compat/tests/test_adapters.py @@ -161,3 +161,17 @@ def test_doi_should_replace_target_URL(self): for link in as_list(bibitem.link or []) if f"{urlparse(link.content).scheme}://{urlparse(link.content).netloc}" == "https://doi.org" )) + + def test_iana_should_replace_target_scheme(self): + adapter = IanaAdapter(self.dirname, "bibxml-iana", self.iana_ref) + bibitem = adapter.resolve() + for link in as_list(bibitem.link or []): + if content := link.__getattribute__("content"): + url_parse = urlparse(content) + self.assertEqual(url_parse.scheme, "https") + self.assertTrue( + all( + urlparse(link.content).scheme == "https" + for link in as_list(bibitem.link or []) + ) + )