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 Oct 24, 2023
1 parent d291024 commit 077472b
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

import isbnlib
from six.moves.urllib.parse import urlparse
from 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."""
assert idutils.is_url(
"https://archive.softwareheritage.org/swh:1:dir:44ac666e75004dd2a27ca0e09e73aecc0e8b426f;origin=https://github.com/amykwebster/MIPseq_2021;visit=swh:1:snp:46bcbe75339295c3d68fcf1257022aae8e6bee40;anchor=swh:1:rev:27839dcc9ef1587086be195349310fb70fbfcaf1"
)

0 comments on commit 077472b

Please sign in to comment.