Skip to content

Commit

Permalink
idutils: make DOIs without suffix invalid
Browse files Browse the repository at this point in the history
Signed-off-by: Micha Moskovic <michamos@gmail.com>
  • Loading branch information
michamos authored and lnielsen committed May 3, 2018
1 parent d47b332 commit 523d9ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion idutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .version import __version__

doi_regexp = re.compile(
"(doi:\s*|(?:https?://)?(?:dx\.)?doi\.org/)?(10\.\d+(.\d+)*/.*)$",
"(doi:\s*|(?:https?://)?(?:dx\.)?doi\.org/)?(10\.\d+(.\d+)*/.+)$",
flags=re.I
)
"""See http://en.wikipedia.org/wiki/Digital_object_identifier."""
Expand Down
7 changes: 7 additions & 0 deletions tests/test_idutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,10 @@ def test_compund_isbn():
assert idutils.is_isbn('0-9752298-0-X')
assert not idutils.is_isbn13('0-9752298-0-X')
assert idutils.is_isbn10('0-9752298-0-X')


def test_doi():
"""Test DOI validation."""
assert idutils.is_doi('10.1000/123456')
assert idutils.is_doi('10.1038/issn.1476-4687')
assert not idutils.is_doi('10.1000/')

0 comments on commit 523d9ba

Please sign in to comment.