Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_url: allow urls with parameters #92

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)