File tree Expand file tree Collapse file tree
colrev/packages/arxiv/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77import typing
88from multiprocessing import Lock
99from pathlib import Path
10- from urllib .parse import urlparse
10+ from urllib .parse import urlparse , parse_qs
1111
1212from pydantic import Field
1313
@@ -95,13 +95,20 @@ def add_endpoint(
9595
9696 # pylint: disable=colrev-missed-constant-usage
9797 else :
98- host = urlparse (params_dict ["url" ]). hostname
98+ parsed_url = urlparse (params_dict ["url" ])
9999
100- if not (host and host .endswith ("arxiv.org" )):
101- raise AssertionError (f"Unexpected URL host: { host } " )
100+ if (
101+ parsed_url .scheme != "https"
102+ or parsed_url .hostname != "arxiv.org"
103+ or parsed_url .path != "/search/"
104+ ):
105+ raise AssertionError (f"Unexpected arXiv URL: { params_dict ['url' ]} " )
102106
103- query = params_dict ["url" ].replace ("https://arxiv.org/search/?query=" , "" )
104- query = query [: query .find ("&searchtype" )]
107+ query_values = parse_qs (parsed_url .query ).get ("query" )
108+ if not query_values :
109+ raise AssertionError ("Missing arXiv search query" )
110+
111+ query = query_values [0 ]
105112
106113 filename = colrev .utils .get_unique_filename (
107114 base_path = path ,
You can’t perform that action at this time.
0 commit comments