feat: 更新references、related_works字段#430
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the validation logic for references, related works, and citations by consolidating them into a single helper function, _check_id_type_id_title_items. However, this change inadvertently removes the URL format validation (using URL_RE) that was previously applied to references and related works. It is recommended to restore this validation within the helper function when the id_type is set to 'url'.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| def check_citations(citations: Any) -> bool: | ||
| if citations is None: | ||
| def _check_id_type_id_title_items(items: Any) -> bool: |
There was a problem hiding this comment.
在重构 check_references 和 check_related_works 之后,它们现在统一使用 _check_id_type_id_title_items 函数进行校验。\n\n然而,原先的实现中,references 和 related_works 中的每个元素都必须是符合 URL_RE 的有效 URL。在新的实现中,如果 id_type 为 "url",代码仅校验了 citation_id 是否为非空字符串,而没有使用 URL_RE 进行格式校验。这会导致 URL 格式校验失效(任何非空字符串都会被视为有效的 URL)。\n\n建议在 _check_id_type_id_title_items 中增加对 id_type == "url" 的校验,例如:\n\npython\n if id_type == "doi":\n if check_doi(citation_id, "paper"):\n return True\n elif id_type == "url":\n if not isinstance(citation_id, str) or not URL_RE.fullmatch(citation_id):\n return True\n elif not isinstance(citation_id, str) or citation_id == "":\n return True\n
No description provided.