Skip to content

Commit

Permalink
is_url: allow urls with parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tmorrell committed Dec 11, 2023
1 parent 99a3920 commit 5922118
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 2 additions & 4 deletions idutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

"""Small library for persistent identifiers used in scholarly communication."""

from __future__ import absolute_import, print_function

import re
from urllib.parse import urlparse

import isbnlib
from six.moves.urllib.parse import urlparse

ENSEMBL_PREFIXES = (
"ENSPMA", # Petromyzon marinus (Lamprey)
Expand Down Expand Up @@ -548,7 +546,7 @@ def is_purl(val):
def is_url(val):
"""Test if argument is a URL."""
res = urlparse(val)
return bool(res.scheme and res.netloc and res.params == "")
return bool(res.scheme and res.netloc)


def is_lsid(val):
Expand Down
7 changes: 7 additions & 0 deletions tests/test_idutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,3 +866,10 @@ def test_ascl():
assert idutils.is_ascl("ascl:1908.011")
assert idutils.is_ascl("ascl:1908.0113")
assert not idutils.is_ascl("1990.0803")


def test_url():
"""Test URL validation."""
for i, expected_schemes, normalized_value, url_value in identifiers:
if url_value:
assert idutils.is_url(url_value)

0 comments on commit 5922118

Please sign in to comment.