File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2029,8 +2029,5 @@ def to_content_disposition(target: str) -> str:
20292029def validate_doi (doi : str ) -> bool :
20302030 if len (doi ) > DOI_MAX_LENGTH :
20312031 return False
2032- prefix = "https://doi.org/|doi.org/|doi:"
2033- doi_prefix = r"10\.\d+"
2034- doi_suffix = r"\S+"
2035- doi_re = re .compile (f"^{ prefix } { doi_prefix } /{ doi_suffix } $" )
2036- return bool (doi_re .match (doi ))
2032+ doi_re = re .compile (r"(10\.(\d)+\/(.+))" )
2033+ return bool (doi_re .search (doi ))
Original file line number Diff line number Diff line change @@ -149,6 +149,13 @@ class Stuff(str, Enum):
149149 "doi:10.1234567890/42" , # longer prefix
150150 "doi:10.1234/42ab:%&*$//crazy-suffix/%/&/" ,
151151 "doi:10.1234/aa" ,
152+ "http://doi.org/10.1234/42" ,
153+ "stillvalid:10.1234/42" ,
154+ "dx.doi.org:10.1234/42" ,
155+ "https://dx.doi.org:10.1234/42" ,
156+ "doi:10.1234/42/a b" ,
157+ "httpss://dx.doi.org:10.1234/42" ,
158+ "doi:10.1234/ 42" ,
152159]
153160
154161
@@ -158,14 +165,11 @@ def test_validate_doi_pass(input):
158165
159166
160167DOI_INVALID_VALUES = [
161- "http://doi.org/10.1234/42" ,
162- "invalid:10.1234/42" ,
163168 "doi:11.1234/42" ,
164169 "doi:101234/42" ,
165170 "doi:10. 1234/42" ,
166171 "doi:10.abc/42" ,
167- "doi:10.1234/ 42" ,
168- "doi:10.1234/42/a b" ,
172+ "10.1234 /42/a b" ,
169173]
170174
171175
You can’t perform that action at this time.
0 commit comments