File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 5757
5858import requests
5959
60+ import re
61+
6062from six import u
6163
6264from .config import config
@@ -370,6 +372,9 @@ def doi_to_qs(doi):
370372
371373 Wikidata Query Service is used to resolve the DOI.
372374
375+ If the DOI is given as a URL or with a "doi:" prefix,
376+ that is removed first.
377+
373378 The DOI string is converted to uppercase before any
374379 query is made. Uppercase DOIs are default in Wikidata.
375380
@@ -395,7 +400,15 @@ def doi_to_qs(doi):
395400 >>> doi_to_qs(doi) == ['Q135403558']
396401 True
397402
403+ >>> doi = 'https://doi.org/10.3390/MICROORGANISMS12071299'
404+ >>> doi_to_qs(doi) == ['Q135390431']
405+ True
406+
407+ >>> doi_to_qs('doi:10.3390/MICROORGANISMS12071299') == ['Q135390431']
408+ True
409+
398410 """
411+ doi = re .sub (r'(?i)^(https?://(www\.|dx\.)?doi\.org/?|doi:)' , '' , doi )
399412 query = SPARQL_PREFIXES + (
400413 'select ?work where {{ ?work wdt:P356 "{doi}" }}' ).format (
401414 doi = escape_string (doi .upper ()))
You can’t perform that action at this time.
0 commit comments