From 077472bd19f2e5b29143c163eaeb929b6cd91245 Mon Sep 17 00:00:00 2001 From: Thomas Morrell Date: Tue, 24 Oct 2023 13:38:02 -0700 Subject: [PATCH] is_url: allow urls with parameters --- idutils/__init__.py | 6 ++---- tests/test_idutils.py | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/idutils/__init__.py b/idutils/__init__.py index 1d753b1..59ba369 100644 --- a/idutils/__init__.py +++ b/idutils/__init__.py @@ -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) @@ -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): diff --git a/tests/test_idutils.py b/tests/test_idutils.py index 949d5e4..3b34c61 100644 --- a/tests/test_idutils.py +++ b/tests/test_idutils.py @@ -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" + )