From cc9b36663896a6304db130a04aca0908f5709d13 Mon Sep 17 00:00:00 2001 From: Antonio Vivace Date: Fri, 22 Mar 2024 17:26:34 +0100 Subject: [PATCH] Allow fetch.txt with file URLs to validate (#154) --- bagit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bagit.py b/bagit.py index 472d231..0200b46 100755 --- a/bagit.py +++ b/bagit.py @@ -774,7 +774,9 @@ def validate_fetch(self): # well formed: parsed_url = urlparse(url) - if not all((parsed_url.scheme, parsed_url.netloc)): + # each parsed url must resolve to a scheme and point to a netloc + # if the scheme is file, netloc is not necessary + if not (all((parsed_url.scheme, parsed_url.netloc)) or parsed_url.scheme == "file"): raise BagError(_("Malformed URL in fetch.txt: %s") % url) def _validate_contents(self, processes=1, fast=False, completeness_only=False):